Fixes in exceptions and default functions
This commit is contained in:
parent
7b381fb884
commit
a1717228bc
1 changed files with 20 additions and 5 deletions
25
src/WPDO.php
25
src/WPDO.php
|
|
@ -108,11 +108,18 @@ class WPDO {
|
|||
|
||||
}
|
||||
|
||||
public function select_to_array($fields, $where_sql, $values) {
|
||||
public function select_to_array($fields=[], $where_sql='', $values=[]) {
|
||||
|
||||
if(count($fields)==0) {
|
||||
|
||||
$fields=$this->table->fields;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if($this->select($fields, $where_sql, $values)) {
|
||||
|
||||
return $this->sth->fetchAll();
|
||||
return $this->sth->fetchAll(\PDO::FETCH_ASSOC);
|
||||
|
||||
}
|
||||
else {
|
||||
|
|
@ -123,7 +130,13 @@ class WPDO {
|
|||
|
||||
}
|
||||
|
||||
public function select_a_row($fields, $where_sql, $values) {
|
||||
public function select_a_row($fields, $where_sql='', $values=[]) {
|
||||
|
||||
if(count($fields)==0) {
|
||||
|
||||
$fields=$this->table->fields;
|
||||
|
||||
}
|
||||
|
||||
if($this->select($fields, $where_sql.' limit 1', $values)) {
|
||||
|
||||
|
|
@ -134,6 +147,8 @@ class WPDO {
|
|||
return $rows[0];
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
else {
|
||||
|
|
@ -175,7 +190,7 @@ class WPDO {
|
|||
|
||||
if(count($fields)!=count($values)) {
|
||||
|
||||
throw new Exception('No valid values for insert in '.$this->table->name);
|
||||
throw new \Exception('No valid values for insert in '.$this->table->name);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -195,7 +210,7 @@ class WPDO {
|
|||
|
||||
if(count($fields)!=count($values_update)) {
|
||||
|
||||
throw new Exception('No valid values for insert in '.$this->table->name);
|
||||
throw new \Exception('No valid values for insert in '.$this->table->name);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue