$st = $this->db()->conn->prepare($sql);
$st->execute();
+ // Params
$form_hidden = '';
$url_params = [
'referer' => (!empty($_SERVER['HTTP_REFERER']) ? urlencode($_SERVER['HTTP_REFERER']) : ''),
];
if ($this->show_hidden_params and !empty(self::$params)) {
+ $ignore = ['limit'];
+
$form_hidden = ''
- .self::form_hidden([],array_merge($this->params2hash(self::$params),[
+ .self::form_hidden($ignore,array_merge($this->params2hash(self::$params),[
'action' => ($add ? 'insert' : 'update'),
'referer' => (!empty($_SERVER['HTTP_REFERER']) ? urlencode($_SERVER['HTTP_REFERER']) : ''),
]))
;
- foreach (self::$params as $p) {
+ foreach (array_diff(self::$params,$ignore) as $p) {
if (!($v = self::p($p))) continue;
$url_params[$p] = $v;
}
+
$url_params['action'] = ($add ? 'insert' : 'update');
} else {
}
#debug($form_hidden);
- if (false and $url_params) {
+ if ($_SERVER['SERVER_NAME'] == 'rent' and $url_params) {
$flat = [];
foreach ($url_params as $k=>$v) {
if ((string)$v === '') continue;
$form_hidden = '';
}
+ // Form
echo '<form class="db edit form-table" method="post" action="'.$form_action.'">'.NB_EOL;
echo '<div class="fields">'.NB_EOL;
$count = 0;
}
public function action($action=null) {
- #if (empty($action)) return;
- #if ($action === null) $action = $this->p('action');
- #debug($action);
if ($action == 'table.fields') {
$rows = $this->fields_rows();
return $this->out($this->info());
} elseif ($action == 'table.delete') {
-# NB 10.12.16 if (!$this->delete($this->p(),$e) and !isset($e['rowCount'])) bye($e);
if (!$this->delete($_POST,$e) and !isset($e['rowCount'])) bye($e);
$this->db()->print_header('Location',$this->url_referer(str_replace('&','&',$this->url_list())));
$this->out($e);
return true;
} elseif ($action == 'table.replace') {
-# NB 10.12.16 if (!$this->replace($this->p(),$e) and !isset($e['rowCount'])) bye($e);
if (!$this->replace($_POST,$e) and !isset($e['rowCount'])) bye($e);
$this->db()->print_header('Location',$this->url_referer());
$this->out($e);
return true;
} elseif ($action == 'table.insert') {
-# NB 10.12.16 if (!$this->insert($this->p(),$e)) bye();
if (!$this->insert($_POST,$e)) bye();
$this->db()->print_header('Location',$this->url_referer());
$this->out($e);
return true;
} elseif ($action == 'table.update') {
-# NB 10.12.16 if (!$this->update($this->p(),$e)) bye($e);
- if (!$this->update($_POST,$e)) bye($e);
+ if ($this->update($_POST,$e) === false) bye($e);
$this->db()->print_header('Location',$this->url_referer());
$this->out($e);
return true;