From b5400a0c7808da6bae095ff54f6d45591c74948f Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Thu, 26 Mar 2015 23:01:37 -0400 Subject: [PATCH] document return values of db_get_* when no match --- db.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/db.php b/db.php index efefbda..9540220 100644 --- a/db.php +++ b/db.php @@ -161,6 +161,7 @@ function _db_printf($str, $args) { } +# helper function function db_send_get($table, $columns, $where, $args) { $sql = "SELECT $columns FROM $table"; if($where) { @@ -171,6 +172,7 @@ function db_send_get($table, $columns, $where, $args) { } +# if no results: returs [] function db_get_rows($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -187,6 +189,7 @@ function db_get_rows($table, $columns, $where = '') { } # like db_get_rows, but return array of hashes. +# if no results: returs [] function db_get_assocs($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -202,6 +205,7 @@ function db_get_assocs($table, $columns, $where = '') { return $rows; } +# if no results: returs [] function db_get_column($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -217,6 +221,8 @@ function db_get_column($table, $columns, $where = '') { return $column; } +# returns first matching row +# if no results: returns false function db_get_row($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -230,6 +236,7 @@ function db_get_row($table, $columns, $where = '') { } # like db_get_row, but return a hash. +# if no results: returns false function db_get_assoc($table, $columns, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); @@ -242,10 +249,11 @@ function db_get_assoc($table, $columns, $where = '') { return $row; } -function db_get_value($table, $columns, $where = '') { +# if no results: returns false +function db_get_value($table, $column, $where = '') { $args = func_get_args(); $args = array_slice($args, 3); - $result = db_send_get($table, $columns, $where, $args); + $result = db_send_get($table, $column, $where, $args); $value = mysql_fetch_row($result); if($value !== false) { -- 1.7.10.4