From: Nicolas Boisselier Date: Thu, 7 Apr 2016 11:24:49 +0000 (+0100) Subject: fix X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=9d4a99d4e508df599b6cfd70a2a3871044e7cf96;p=nb.git fix --- diff --git a/lib/php/db.php b/lib/php/db.php index 58a44594..41b6bebd 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -133,7 +133,7 @@ class Db extends nb { if (empty($this->pdo)) return false; # Type - if (!$this->type(null)) $this->bye("unknow type = `".$this->type."`"); + if (!$this->type(null)) $this->bye("Unknow type = `".$this->type."`"); # Connect if ($this->type('use_path') and !is_readable($this->name)) { @@ -146,7 +146,7 @@ class Db extends nb { #if (isset($this->pdo_error)) $this->conn->setAttribute($this->pdo_error[0], $this->pdo_error[1]); } catch (PDOException $e) { - throw new CustomException('Connection failed: ' . $e->getMessage(), (int)$e->getCode( )); + throw new Exception('Connection failed: ' . $e->getMessage(), (int)$e->getCode( )); self::bye('Connection failed: ' . $e->getMessage()); } diff --git a/lib/php/db/table.php b/lib/php/db/table.php index d56fe26d..920452c3 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -227,7 +227,7 @@ Class Table extends nb { } public function fields_keys(&$others=array()) { - + $fields_keys = array(); foreach ($this->fields() as $name => $f) { @@ -247,7 +247,7 @@ Class Table extends nb { foreach (array_diff(self::$params,$ignore) as $p) { if ($v=self::p($p)) { if (self::p('debug')) $h .= ""; - $h .= ''; + $h .= ''.NB_EOL; } } return $h; @@ -384,21 +384,6 @@ Class Table extends nb { $next = 999999; } - /* - if ($prev>=0) $html .= ''; - - $html .= '
  • '.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.' results
  • '; - - if ($next<$tot) $html .= ''; - - if ($html) $html = '' - .''.NB_EOL - ; - */ if ($prev>=0) $html .= '<< '; $html .= ''.($tot ? ($x+1) : 0).' - '.( $count<($x+$y) ? $count : ($x+$y) ).' / '.$tot.' results'; @@ -602,13 +587,12 @@ Class Table extends nb { if ($opt['is_html'] and !$this->p('action') and !$this->p('inc')) { echo $this->html_menu(); - - } elseif ($opt['is_html'] and !$this->p('inc')) { - echo $this->form_hidden(); - } - if ($opt['is_html']) echo '
    '.NB_EOL; + if ($opt['is_html']) { + echo '
    '.NB_EOL; + if (!$this->p('inc')) echo $this->form_hidden(); + } # Use the module out when format unknow $out_conf = null; @@ -695,10 +679,10 @@ Class Table extends nb { $query = $this->db()->conn->query($select_count[1]); } elseif ($where) { - $debug = "Table.rows(): Using $sql_count"; $sql_count = $sql; $sql_count = preg_replace('/ (ORDER|LIMIT) .*?$/s','',$sql_count); $sql_count = preg_replace('/^SELECT .*FROM/s','SELECT count(*) FROM ',$sql_count); + $debug = "Table.rows(): Using $sql_count"; $query = $this->db()->conn->query($sql_count); } else { diff --git a/lib/php/out.php b/lib/php/out.php index fd0fc321..b8f597c9 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -379,6 +379,8 @@ function out_tag(&$row,&$o) { foreach ($row as $k => $v) { + $v = out::escape($v); + # Inside tag, ex: label if (isset($o['tag_key'])) { $v = '<'.$o['tag_key'].'>'.$k.''.$v; @@ -387,12 +389,11 @@ function out_tag(&$row,&$o) { # Tag = o[tag] or key if (isset($o['tag'])) { $class = is_numeric($k) ? '' : ' class="'.$k.'"'; - $k = $o['tag']; + $k = $o['tag']; } else { $class = ''; } - $v = out::escape($v); echo '' .(NB_EOL ? ' ' : '') ."<$k$class>$v"