<?php
$con = &$mysqli; //mysqli_connect('localhost', 'root', '', 'oop_crud');
class Student
{
/*
var ?int $id;
var string $name;
var int $nrp;
var string $email;
var int $major;
var string $image;
function __construct(string $name, int $nrp, string $email, string $image, int $major, int $id = null)
{
$this->id = $id;
$this->name = $name;
$this->nrp = $nrp;
$this->email = $email;
$this->major = $major;
$this->image = $image;
}
*/
static function create_and_save(string $name, int $nrp, string $email, int $major, string $image)
{
global $con;
//echo mysqli_ping($con);
$sql = "INSERT INTO `student` VALUES (NULL, '$name', $nrp, '$email', $major, '$image');";
$q = mysqli_query($con, $sql);
if ($q) {
echo 'DATA INSERTION SUCCESS';
} else {
var_dump(mysqli_error($con));
}
}
}
Student::create_and_save(
'John Jane', 213123123, 'test2@gmail.com', 5, 'img/doesnotexist'
);