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) {