X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=db.php;h=f39d5e006afa1b259964be75c6c5b9fc488df6d8;hb=3faf64c6a1e0cbd4f880da951775c41fb8a6f0ab;hp=4a58db863a280bcfc9ffe1edd852b34586527360;hpb=e86ee66741adaf034eab0b6a9c857cd1caa8cd0c;p=wfpl.git diff --git a/db.php b/db.php index 4a58db8..f39d5e0 100644 --- a/db.php +++ b/db.php @@ -166,6 +166,22 @@ function db_get_rows($table, $columns, $where = '') { return $rows; } +# like db_get_rows, but return array of hashes. +function db_get_assocs($table, $columns, $where = '') { + $args = func_get_args(); + $args = array_slice($args, 3); + $result = db_send_get($table, $columns, $where, $args); + + $rows = array(); + while($row = mysql_fetch_assoc($result)) { + $rows[] = $row; + } + + mysql_free_result($result); + + return $rows; +} + function db_get_column($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -193,6 +209,19 @@ function db_get_row($table, $columns, $where = '') { return $row; } +# like db_get_row, but return a hash. +function db_get_assoc($table, $columns, $where = '') { + $args = func_get_args(); + $args = array_slice($args, 3); + $result = db_send_get($table, $columns, $where, $args); + + $row = mysql_fetch_assoc($result); + + mysql_free_result($result); + + return $row; +} + function db_get_value($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3);