return $this->db()->sql_name($value === null ? $this->name : $value);
}
- public function insert($hvalues,&$info=array()) {
+ public function replace($hvalues,&$info=array()) {
+ return $this->insert($hvalues,$info,'REPLACE');
+ }
+
+ public function insert($hvalues,&$info=array(),$insert_word='INSERT') {
if (empty($info['values'])) $info['values'] = array();
$info['values'] = $hvalues;
}
$sql =
- 'INSERT INTO '. $this->sql_name() . ' (' . join(',',array_values($sql_names)).')'
+ $insert_word.' INTO '. $this->sql_name() . ' (' . join(',',array_values($sql_names)).')'
#.' VALUES (' . join(',',$values).')'
.' VALUES (' . join(',',ar_map('":$a"',array_keys($fields))) . ')'
;
header('Location: '.$this->url_referer(str_replace('&','&',$this->url_list())));
return true;
+ } elseif ($action == 'table.replace' or $action == 'replace') {
+ if (!$this->replace($this->p(),$e)) bye($e);
+ header('Location: '.$this->url_referer());
+ $this->out($e);
+ return true;
+
} elseif ($action == 'table.insert' or $action == 'insert') {
if (!$this->insert($this->p(),$e)) bye($e);
header('Location: '.$this->url_referer());