diff --git a/src/WPDO.php b/src/WPDO.php index 2f23c86..3266749 100644 --- a/src/WPDO.php +++ b/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); }