我有这个错误:
致命错误:' 1000'的最大功能嵌套级别到达,流产!在第47行的C:\ xampp \ htdocs \ progettoPersonale \ libs \ DbConnector.php
我有两个类,但是当我尝试知道错误的行数时
<?php
class UserModel
{
private $dbconn = null ;
public function __construct()
{
$this->dbconn = new DbConnector();
}
public function checkLogin($username, $password ){
$new_password=password_hash($password, PASSWORD_DEFAULT);
$res =$this->dbconn->select(
array('*'),
'iscritti',
"nome_utente='".$this->dbconn->escape($username)."' && password='".$this->dbconn->escape($new_password)."'"
);
$resault =$this->dbconn->num_rows($res);
if($resault==1){
return true ;
}else{
return false ;
}
}
}
<?php
class DbConnector
{ private $_dbconn = null;
public function __construct()
{
$this->_dbconn= new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_DATABASE);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
}
public function select( $fields, $table, $conditions = '1' ) {
$query = "SELECT ";
$query .= implode( ', ', $fields );
$query .= " FROM ";
$query .= $table;
$query .= " WHERE ";
$query .= $conditions;
var_dump($query);
return $this->_dbconn->query($query);
}
public function insert($table,$fields,$values){
$query = "INSERT INTO" .$table."";
$query.= "(".implode(',', $fields).")";
$query.= "VALUES" ;
$query.= "(".implode(',', $values).")";
return $this->_dbconn->query($query);
}
public function fetch_assoc($res){
return $res->fetch_assoc();
}
public function query($query){
return $this->_dbconn->query($query);
}
public function escape($string){
return $this->_dbconn->real_escape_string($string);
}
public function last_id(){
return $this->last_id();
}
public function num_rows(){
return $this->num_rows();
}
public function close_con(){
$this->close_con();
}
}
答案 0 :(得分:0)
num_rows
自称。
public function num_rows(){
return $this->num_rows();
}
它会一直调用自己,直到你遇到这个错误。你有意这么说吗?
public function num_rows($res){
return $res->num_rows;
}