From 92835df6623bca5b7f5a966d2af154dc08f9ab03 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 29 Mar 2015 18:56:42 +0200 Subject: [PATCH] port updated sql library from satoko --- _sakura/components/database/mysql.php | 34 ++++++++++++++------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/_sakura/components/database/mysql.php b/_sakura/components/database/mysql.php index 4f9a3fd..aa40e4e 100644 --- a/_sakura/components/database/mysql.php +++ b/_sakura/components/database/mysql.php @@ -1,6 +1,6 @@ $value) { - $prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', '); + if(strlen($value)) + $prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', '); } - + $prepare .= ')' . ($i ? ';' : ' VALUES '); - + } - + // Actually prepare the preration $query = self::$sql->prepare($prepare); - + // Bind those parameters foreach($data as $key => $value) { - $query->bindParam(':'. $key, $value); - + if(strlen($value)) + $query->bindParam(':'. $key, $value); + // Unset variables to be safe unset($key); unset($value); @@ -205,12 +207,12 @@ class Database { // Execute the prepared statements with parameters bound $result = $query->execute(); - + // Return whatever can be returned return $result; - + } - + // Update data in the database public static function update($table, $data) {