Fixes in exceptions and default functions

This commit is contained in:
absurdo 2023-11-18 10:57:05 +01:00
parent 7b381fb884
commit a1717228bc

View file

@ -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)) {
@ -135,6 +148,8 @@ class WPDO {
}
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);
}