ho il seguente errore:
Warning: Parameter 2 to mysqli_stmt::bind_param() expected to be a reference, value given
lo script si compone in due classi
class usermodel
{
private $dbCon = null;
public function __construct()
{
$this->dbCon = new DbCon();
}
public function login($email, $password)
{
$query = "SELECT * FROM members WHERE email=? LIMIT 1";
$this->dbCon->preparestatement($query);
$param_type = 'S';
$this->dbCon->bindParamsToStatement($param_type,array($email));
$this->dbCon->execStartement();
$this->dbCon->storeResult();
$user_id = 0;
$username = '';
$db_password = '';
$salt = '';
$this->dbCon->bindResult( &$user_id, &$username, &$db_password, &$salt));
$this->dbCon->fetchStartement();
$password = hash('sha512', $password . $salt);
class DbCon
{
private $_dbCon = null;
private $_statement = NULL;
public function __construct()
{
$this->_dbCon = new mysqli('localhost', 'root', '', 'oop');
if ($this->_dbCon->errno) {
echo 'errore di conessione' . $this->_dbCon->error;
die();
}
// inizzio metodi statement
public function preparestatement($statement){
$this->_statement = $this->_dbCon->prepare($statement);
}
public function bindParamsToStatement( $type, $params ){
call_user_func_array( array( $this->_statement, 'bind_param' ), array_merge( (array) $type, $params ) );
}
public function execStartement(){
return $this->_statement->execute();
}
public function storeResult(){
$this->_statement->store_result();
}
public function bindResult($params){
$this->_statement->bind_result($params);
}
public function fetchStartement(){
return $this->_dbCon->fetch();
}
public function closestartement(){
$this->_dbCon->close();
}
}
sapete anche come passare in modo dinamico i valori a bind_result()
mi da il seguente errore Warning: mysqli_stmt::bind_result(): Number of bind variables doesn't match number of fields in prepared statement in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 102
Fatal error: Call to undefined method mysqli::fetch() in C:\Users\giuliano\PhpstormProjects\catalogoMvc\lib rerie\dbCon.php on line 106
grazzie per l aiuto