port updated sql library from satoko
This commit is contained in:
parent
7acd3999cb
commit
92835df662
1 changed files with 18 additions and 16 deletions
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
/*
|
||||
* MySQL PDO based database engine
|
||||
* Sakura MySQL Database Engine
|
||||
*/
|
||||
|
||||
namespace Sakura;
|
||||
|
@ -85,7 +85,7 @@ class Database {
|
|||
public static function fetch($table, $fetchAll = true, $data = null, $order = null, $limit = null, $group = null, $distinct = false, $column = '*') {
|
||||
|
||||
// Begin preparation of the statement
|
||||
$prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . $column .' FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`';
|
||||
$prepare = 'SELECT '. ($distinct ? 'DISTINCT ' : '') . ($column == '*' ? '' : '`') . $column . ($column == '*' ? '' : '`') .' FROM `' . Configuration::getLocalConfig('db', 'prefix') . $table . '`';
|
||||
|
||||
// If $data is set and is an array continue
|
||||
if(is_array($data)) {
|
||||
|
@ -184,6 +184,7 @@ class Database {
|
|||
|
||||
// Do more shit, don't feel like describing this so yeah
|
||||
foreach($data as $key => $value) {
|
||||
if(strlen($value))
|
||||
$prepare .= ($i ? ':' : '`') . $key . ($i ? '' : '`') . ($key == key(array_slice($data, -1, 1, true)) ? '' : ', ');
|
||||
}
|
||||
|
||||
|
@ -196,6 +197,7 @@ class Database {
|
|||
|
||||
// Bind those parameters
|
||||
foreach($data as $key => $value) {
|
||||
if(strlen($value))
|
||||
$query->bindParam(':'. $key, $value);
|
||||
|
||||
// Unset variables to be safe
|
||||
|
|
Reference in a new issue