From 3c22a10c40837b1695ae04d120bbfc68da01059c Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Tue, 8 Jun 2010 20:04:48 +0200 Subject: add TableRRepo class and use it --- class/CommonTable.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'class/CommonTable.php') diff --git a/class/CommonTable.php b/class/CommonTable.php index 1102c4d..e049188 100644 --- a/class/CommonTable.php +++ b/class/CommonTable.php @@ -81,7 +81,7 @@ abstract class CommonTable $res = $this->db->exec($sql); if ($res===false) { $err = $this->db->errorInfo(); - throw new Exception($err[2]); + throw new Exception("\nSQL: $sql\nERROR: ".$err[2]."\nCODE:"); } return $res; } @@ -197,7 +197,7 @@ abstract class CommonTable * * @return hashtable */ - public function getAllArray($fieldkey, $fieldvalue) + public function getHashtable($fieldkey, $fieldvalue) { $crit = array('FIELDS' => array($fieldkey, $fieldvalue), 'ORDER' => $fieldkey); @@ -207,6 +207,22 @@ abstract class CommonTable } return $tab; } + + /** + * Retrieve a big array with all date from the table + * + * @param array|string $crit for the request + * + * @return array, index is rowid, value is a hastable + */ + public function getArray($crit='') + { + $tab = array(); + foreach ($this->request($crit) as $id => $data) { + $tab[$id] = $data; + } + return $tab; + } } ?> \ No newline at end of file -- cgit