I am new to both php and mysql and am trying to understand what is going on in this function below. I understand the INSERT INTO portion but the bind_param is where it send to the database? Other question, how can I implement PHP password_hash() on the $item 'password' property and then store that hash. Hopefully this is the right forum for this question. Thanks alot!
Code: Select all
public function createEmployee($item) {
$stmt = mysqli_prepare($this->connection,
"INSERT INTO employees (
firstname,lastname,password,title,departmentid,officephone,cellphone,
email,street,city,state,zipcode,office,photofile)
VALUES (?, ?, ?, ?, ?, ?,?,?,?,?,?,?,?)");
$this->throwExceptionOnError();
mysqli_stmt_bind_param($stmt, 'sssisssssssss', $item->firstname, $item->lastname, $item->password,
$item->title, $item->departmentid, $item->officephone, $item->cellphone,
$item->email, $item->street, $item->city, $item->state,
$item->zipcode, $item->office, $item->photofile
);
$this->throwExceptionOnError();
mysqli_stmt_execute($stmt);
$this->throwExceptionOnError();
$autoid = mysqli_stmt_insert_id($stmt);
mysqli_stmt_free_result($stmt);
mysqli_close($this->connection);
return $autoid;
}