diff options
author | Remi Collet <fedora@famillecollet.com> | 2010-06-08 20:04:48 +0200 |
---|---|---|
committer | Remi Collet <fedora@famillecollet.com> | 2010-06-08 20:04:48 +0200 |
commit | 3c22a10c40837b1695ae04d120bbfc68da01059c (patch) | |
tree | 625b2a793b9999538356feee1cb9f8767f7f0d19 /class/CommonTable.php | |
parent | 53454761ed4d619b328d7cb5f628daafe127efb7 (diff) |
add TableRRepo class and use it
Diffstat (limited to 'class/CommonTable.php')
-rw-r--r-- | class/CommonTable.php | 20 |
1 files changed, 18 insertions, 2 deletions
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 |