From a39dd45790cfcc07cc7d849a2190a9b76adfc152 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 25 May 2009 10:06:49 +0000 Subject: [PATCH] Two minor changes. Version bumped to 1.1. --- ChangeLog.txt | 17 +++++++++++++++++ litemysql.lib.php | 15 ++++++++++----- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 4ce941f..f5e2281 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,20 @@ +LiteMySQL 1.1.1 +----------------------------------- +Date: 25-May-2009 + +- Changed the find_all() method now + returns null instead of false if now + rows are returned. This is so that you + can run the result through count(), which + evals false to 1, and null to 0. + +- Changed the count() method to return + an integer with the count value rather + than a string. + +----------------------------------- + + LiteMySQL 1.1 ----------------------------------- Date: 21-May-2009 diff --git a/litemysql.lib.php b/litemysql.lib.php index 6eb8816..1fb7f89 100644 --- a/litemysql.lib.php +++ b/litemysql.lib.php @@ -2,7 +2,7 @@ /* - Class: LiteMySQL v1.1 + Class: LiteMySQL v1.1.1 http://code.google.com/p/litemysql/ Simple & easy to use class to automate the repetative & boring stuff. @@ -374,7 +374,7 @@ class LiteMySQL { * @param conditions conditions to match, accepted input is string, int, or array * @param options additional options to pass in the query * @param index row value to use as array key for each row - * @return array with result rows or false + * @return array with result rows or null */ function find_all ($conditions = null, $options = array(), $index = null) { $sql = $this->build_find_query($conditions, $options); @@ -400,7 +400,7 @@ class LiteMySQL { } } - return false; + return null; } /** @@ -480,7 +480,12 @@ class LiteMySQL { return $this->find_all($conditions, $options); } - + /** + * Count number of matching rows to specified conditions and options + * @param conditions conditions to match, accepted input is string, int, or array + * @param options additional options to pass in the query + * @return integer with row count or null + */ function count ($conditions = null, $options = '') { $query = 'SELECT '; if ( is_array($options) ) { @@ -498,7 +503,7 @@ class LiteMySQL { } if ( $result = $this->query($query) ) { $count = mysql_fetch_assoc($result); - return $count['COUNT(*)']; + return (int)$count['COUNT(*)']; } return null; }