Fixes in wpdo
This commit is contained in:
parent
bea8e57a33
commit
9ea2a28f95
4 changed files with 47 additions and 29 deletions
22
src/WPDI.php
22
src/WPDI.php
|
|
@ -44,7 +44,7 @@ class WPDI {
|
|||
|
||||
if(WPDI::$host_db=='' || WPDI::$db=='') {
|
||||
|
||||
echo 'Cannot connect to the mysqldb';
|
||||
$this->txt_error='Cannot connect to the mysqldb';
|
||||
|
||||
return false;
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ class WPDI {
|
|||
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
|
||||
|
||||
//$this->conn=new \PDO(WPDI::$driver.':host='.WPDI::$host_db.';dbname='.WPDI::$db, WPDI::$login_db, WPDI::$pass_db);
|
||||
$this->conn=new mysqli(WPDI::$host_db, WPDI::$login_db, WPDI::$pass_db, WPDI::$db);
|
||||
$this->conn=new \mysqli(WPDI::$host_db, WPDI::$login_db, WPDI::$pass_db, WPDI::$db);
|
||||
|
||||
WPDI::$mconn=$this->conn;
|
||||
|
||||
|
|
@ -73,6 +73,8 @@ class WPDI {
|
|||
}
|
||||
else {
|
||||
|
||||
$this->txt_error='Cannot connect to the mysqldb';
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
|
@ -86,16 +88,16 @@ class WPDI {
|
|||
//$this->sth->execute([$values]);
|
||||
|
||||
return $this->sth->execute($values);*/
|
||||
|
||||
return $mysqli->execute_query($query, $values);
|
||||
//echo $this->conn;
|
||||
return $this->conn->execute_query($query, $values);
|
||||
|
||||
}
|
||||
|
||||
public function get_result() {
|
||||
/*public function get_result() {
|
||||
|
||||
return $this->sth->fetchAll();
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
public function select($fields, $where_sql, $values) {
|
||||
|
||||
|
|
@ -113,7 +115,7 @@ class WPDI {
|
|||
|
||||
return $result;*/
|
||||
|
||||
return $this->conn->execute_query($query, $value);
|
||||
return $this->conn->execute_query($query, $values);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -126,13 +128,15 @@ class WPDI {
|
|||
}
|
||||
|
||||
|
||||
$result=$this->conn->select($fields, $where_sql, $values);
|
||||
$result=$this->select($fields, $where_sql, $values);
|
||||
|
||||
if($result) {
|
||||
|
||||
//return $this->sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$rows=$result->fetch_all(MYSQLI_ASSOC);
|
||||
|
||||
return $rows;
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
|
|
@ -254,7 +258,7 @@ class WPDI {
|
|||
/*$this->sth=$this->conn->prepare($query);
|
||||
|
||||
return $this->sth->execute($final_values);*/
|
||||
return $this->query($query, $values);
|
||||
return $this->query($query, $final_values);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ class WPDO {
|
|||
|
||||
if($this->select($fields, $where_sql.' limit 1', $values)) {
|
||||
|
||||
$rows=$this->sth->fetchAll();
|
||||
$rows=$this->sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
if(count($rows)>0) {
|
||||
|
||||
|
|
@ -163,7 +163,7 @@ class WPDO {
|
|||
|
||||
if($this->query('select count(*) from '.$this->table->name.' '.$where_sql, $values)) {
|
||||
|
||||
$rows=$this->sth->fetchAll();
|
||||
$rows=$this->sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
if(count($rows)>0) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue