mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 01:39:22 +02:00
Patching from master
OTS_House refactor code + $db->update with nulls
This commit is contained in:
parent
c2ec468246
commit
1fcdd54c94
@ -184,8 +184,14 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
|||||||
$query = 'UPDATE '.$this->tableName($table).' SET ';
|
$query = 'UPDATE '.$this->tableName($table).' SET ';
|
||||||
|
|
||||||
$count = count($fields);
|
$count = count($fields);
|
||||||
for ($i = 0; $i < $count; $i++)
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$query.= $this->fieldName($fields[$i]).' = '.$this->quote($values[$i]).', ';
|
$value = 'NULL';
|
||||||
|
if ($values[$i] !== null) {
|
||||||
|
$value = $this->quote($values[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$query.= $this->fieldName($fields[$i]).' = '.$value.', ';
|
||||||
|
}
|
||||||
|
|
||||||
$query = substr($query, 0, -2);
|
$query = substr($query, 0, -2);
|
||||||
$query.=' WHERE (';
|
$query.=' WHERE (';
|
||||||
|
@ -60,12 +60,7 @@ class OTS_House extends OTS_Row_DAO
|
|||||||
private $tiles = array();
|
private $tiles = array();
|
||||||
|
|
||||||
public function load($id) {
|
public function load($id) {
|
||||||
$this->data = $this->db->query('SELECT * FROM `houses` WHERE `id` = ' . $id )->fetch();
|
$this->data = $this->db->query('SELECT * FROM `houses` WHERE `id` = ' . $id )->fetch(PDO::FETCH_ASSOC);
|
||||||
foreach($this->data as $key => $value) {
|
|
||||||
if(is_numeric($key)) {
|
|
||||||
unset($this->data[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function find($name)
|
public function find($name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user