For some reason code completion is worry on native php code such as bind_param(), prepare() and execute(). I get this warning: method 'bind_param' not found in class. What is the problem?
if ($this->comparePassword ( $password, $confirmPass )) {
// Generating password hash
$password_hash = PassHash::hash ( $password );
// insert query
$stmt = $this->conn->prepare ( "INSERT INTO seeker(first_name, last_name, email, password, parish) values(?, ?, ?, ?, ?)" );
$stmt->bind_param ( "sssss", $fName, $lName, $email, $password_hash, $parish );
$result = $stmt->execute ();
$stmt->close ();
// Check for successful insertion
if ($result) {
// User successfully inserted
return USER_CREATED_SUCCESSFULLY;
} else {
// Failed to create user
return USER_CREATE_FAILED;
}
} else {
return PASSWORDS_DO_NOT_MATCH;
}
} else {
// User with same email already existed in the db
return USER_ALREADY_EXISTED;
}
Here is the code for the custom class
class DbConnect {
private $conn;
function __construct() {
}
/**
* Establishing database connection
* @return database connection handler
*/
function connect() {
include_once dirname(__FILE__) . './Config.php';
// Connecting to mysql database
$this->conn = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME); //EDIT TO BE PDO
// Check for database connection error
if (mysqli_connect_errno()) { //EDIT TO BE PDO
echo "Failed to connect to MySQL: " . mysqli_connect_error(); //EDIT TO BE PDO
}
// returning connection resource
return $this->conn;
}
}