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);
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);
db_send_query($sql);
}
-# to be consistant with the syntax of the other db functions, $values can be an
+# to be consistent with the syntax of the other db functions, $values can be an
# array, a single value, or multiple parameters.
#
-# as usual the where clause stuff is optional, but it will ofcourse update the
+# as usual the where clause stuff is optional, but it will of course update the
# whole table if you leave it off.
#
# examples:
$num_fields = count($columns);
if(is_array($values)) {
+ $values = array_values($values);
$args = array_slice($args, 1);
} else {
$values = array_slice($args, 0, $num_fields);
$args = array_slice($args, 1);
$sql .= ' ';
- # any left for where claus arguments?
+ # any left for printf arguments?
if($args) {
$sql .= _db_printf($where, $args);
} else {