Browse Source

insert standart

git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/legacy@83 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
master
akulikov 16 years ago
parent
commit
0520bca6f1
  1. 9
      classes/Model.class.php

9
classes/Model.class.php

@ -96,11 +96,14 @@ abstract class Model
function insert($data, $postfix = '') function insert($data, $postfix = '')
{ {
$sql = '';
$keys = array();
$values = array();
foreach ($data as $key => $val) { foreach ($data as $key => $val) {
$sql .= $key.'="'.$this->escape($val).'", ';
$keys[] = $key;
$values[] = $this->escape($val);
} }
return $this->query('INSERT '.$this->table.' SET '.rtrim($sql, ', ').' '.$postfix);
return $this->query('INSERT INTO '.$this->table.' ('.implode(',', $keys).") VALUES('".implode("','", $values)."') ".$postfix);
} }
function delete($id) function delete($id)

Loading…
Cancel
Save