The following code has 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 - Below is the execQuery () function that is in 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
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 error happens?
- PDO is enabled
- PHP Version 5.6.15