From 2b31e8a6f30ebcd145b3394ac1a2ef8a768924ac Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Fri, 8 Jan 2010 03:10:43 +0000 Subject: The download module mostly works/looks the way it should. Bayonet_SQL now checks for a valid result, and if it is invalid just return. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@460 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- includes/sql.class.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'includes/sql.class.php') diff --git a/includes/sql.class.php b/includes/sql.class.php index 6bda00f..c32de63 100644 --- a/includes/sql.class.php +++ b/includes/sql.class.php @@ -53,6 +53,14 @@ class Bayonet_SQL return mysqli_select_db($GLOBALS['___mysqli_ston'], $db); } + private function validResult($p_result) + { + if($this->Rows($p_result) > 0) + return true; + else + return false; + } + public function Query($str) { global $db_queries; @@ -78,6 +86,12 @@ class Bayonet_SQL $db_fetches++; decho('Fetching result'); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return array(); + } + while ($row = mysqli_fetch_array($p_result, MYSQLI_ASSOC)) { $result[] = $row; @@ -94,6 +108,12 @@ class Bayonet_SQL decho("Fetching object result"); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return (object)array(); + } + while ($row = mysqli_fetch_object($p_result, $class)) { if($no_array == true) @@ -121,6 +141,12 @@ class Bayonet_SQL decho("Fetching single row"); + if(!$this->validResult($p_result)) + { + decho('Result was not valid.'); + return array(); + } + while ($row = mysqli_fetch_assoc($p_result)) { $result = $row; } -- cgit