- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
public function save() {
if (!empty(self::$single)) {
if (isset(self::$single['id'])) {
$id = self::$single['id'];
unset(self::$single['id']);
$arraySetters = [];
foreach (self::$single as $key => $value) {
$arraySetters[] = '`'.$key.'` = \''.$value.'\'';
}
self::$single['id'] = $id;
self::$exec = static::$db->prepare('UPDATE '.self::$table.' SET '.implode(', ', $arraySetters).' WHERE `id` = '.$id.' LIMIT 1');
return self::$exec->execute();
} else {
$arrayKeys = [];
$arrayValues = [];
foreach (self::$single as $key => $value) {
$arrayKeys[] = '`'.$key.'`';
$arrayValues[] = '\''.$value.'\'';
}
self::$exec = static::$db->prepare('INSERT INTO '.self::$table.' ('.implode(', ', $arrayKeys).') VALUES ('.implode(', ', $arrayValues).')');
if ($status = self::$exec->execute()) {
self::$single['id'] = static::$db->lastInsertId();
}
return $status;
}
}
return false;
}
Fike 12.10.2015 22:30 # +2
НАРЦИССИСТ ЕБАНЫЙ
bormand 12.10.2015 22:32 # +1
Forever alone
CHayT 13.10.2015 09:23 # 0
besprincypniycentner 13.10.2015 09:40 # +6
HiNeX 13.10.2015 10:18 # 0
guest 13.10.2015 10:14 # 0
> return self::$exec->execute();
нахуя в свойство-то пихать?
HiNeX 13.10.2015 10:17 # 0