-1
The following code displays an undefined method error on the line:
$result = ($exec!==false)?$exec->fetchAll(PDO::FETCH_ASSOC):$exec;
public function getConnection(){
global $conn;
$this->conn = $conn;
if (!is_object($this->conn)) {
$this->conn = parent::connect();
}
}
public function select($qry){
self::getConnection();
$result = false;
try{
$exec = parent::execQuery($qry,$this->conn);
}catch (PDOException $e){
die($e->getMessage());
}
$result = ($exec!==false)?$exec->fetchAll(PDO::FETCH_ASSOC):$exec;
return $result;
}
UPDATE:
1.0 - The function follows below execQuery() who is in the Parent class
connect
public function execQuery($qry,$con){
$exec = $con->query($qry);
if($exec === false){
//ob_clean();
throw new Exception($qry."<br>".$con->error);
}else{
return $exec;
}
}
UPDATE:
1.1 - Below is the
print_r($this->conn)
mysqli Object ( [affected_rows] => 0 [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $ [client_version] => 50011 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.5-10.1.9-MariaDB [server_version] => 50505 [stat] => Uptime: 235 Threads: 1 Questions: 10 Slow queries: 0 Opens: 1 Flush tables: 1 Open tables: 12 Queries per second avg: 0.042 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 9 [warning_count] => 0 ) mysqli Object ( [affected_rows] => -1 [client_info] => mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $ [client_version] => 50011 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => localhost via TCP/IP [info] => [insert_id] => 0 [server_info] => 5.5.5-10.1.9-MariaDB [server_version] => 50505 [stat] => Uptime: 235 Threads: 1 Questions: 10 Slow queries: 0 Opens: 1 Flush tables: 1 Open tables: 12 Queries per second avg: 0.042 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 9 [warning_count] => 0 )
Why this mistake happens?
- PDO is enabled
- PHP Version 5.6.15
There’s something really wrong there,
mysqli_result::fetchAll()
?– rray
Yeah, bro. kkkkkkk I DON’T KNOW EITHER!
– Lollipop
Take a look at
execQuery()
– rray
rray, edited..
– Lollipop
In select, give a print_r on
$this->conn
and$exec
or has variable being overwritten or some file being pulled wrong.– rray
rray:
mysqli_result Object ( [current_field] => 0 [field_count] => 5 [lengths] => [num_rows] => 0 [type] => 0 )
– Lollipop
It’s not PDO, mysqli, there’s something wrong with your files.
– rray
I’ll put up the $this->Conn
– Lollipop
Ta edited, rray
– Lollipop
It is easier for you to locate everything that is "mysqli" in your files, and consequently find the error. Virtually all good code editors have a file search.
– Bacco
Everything is in mysqli
$con = @new mysqli(self::DB_HOST, self::DB_USER, self::DB_PASS, self::DB_NOME);
– Lollipop
Why does this error occur? PHP version/?
– Lollipop
The PDO has the
fetchAll()
and Mysqli from php5.3 has thefetch_all()
– rray
Either it is mysqli or it is PDO... You need to choose which one to use, there is no way to mix pieces of one into the other. If you open the connection with PDO, you have to use only the functions or methods of PDO, in the same way, if opened with mysqli, you have to use only those of mysqli.
– Bacco
Bacco, that explains the confusion or the problem?
– Lollipop
But they’re complaining about mysqlnd and not
PDO
, themysqlnd
is activated?– deFreitas
@deFreitas he was not using PDO, see the line in the comments:
$con = @new mysqli(self::DB_HOST, self::DB_USER, self::DB_PASS, self::DB_NOME);
– Bacco
@Bacco is exactly what I’m saying, he said he has the PDO activated but it doesn’t make a difference because he’s using mysqlnd
– deFreitas