From: Nicolas Boisselier Date: Mon, 6 Jul 2015 16:33:14 +0000 (+0100) Subject: config dir X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=7bff2e01c9dcf8fdc9eb2b3168b6bbc385625e9c;p=nb.git config dir --- diff --git a/lib/php/db.php b/lib/php/db.php index 86b26f10..11df6342 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -172,26 +172,6 @@ EOF; return true; } - function initParams($tables=null) { - - if ($tables === null) $tables = $this->tables(); - - #$_REQUEST['table'] = @$_REQUEST['table'] ? preg_replace('/^([\w\d_-]+).*$/','\1',$_REQUEST['table']) : $tables[0]; - $_REQUEST['table'] = @$_REQUEST['table'] ? $_REQUEST['table'] : ($tables === null ? '' : $tables[0]); - if (@$_REQUEST['sql']) $_REQUEST['table'] = $_REQUEST['sql']; - - $_REQUEST['limit'] = @$_REQUEST['limit'] - ? preg_replace('/^(\d+)(,\d+).*$/','\1\2',$_REQUEST['limit']) - : ( preg_match('/^(curl|lynx|lwp)/',@$_SERVER['HTTP_USER_AGENT']) ? 999999 : 50 ) - ; - - $_REQUEST['format'] = @$_REQUEST['format'] ? $_REQUEST['format'] : 'table'; - - #$_REQUEST['op'] = strtoupper(@$_REQUEST['op']) == 'AND' ? 'AND' : 'OR'; - $_REQUEST['op'] = strtoupper(@$_REQUEST['op']) == 'OR' ? 'OR' : 'AND'; - - } - function html_menu() { $r = ''; @@ -202,9 +182,7 @@ EOF; ; foreach ($this->tables() as $table) { - #$count = $table->rowCount(); $r .= ''.PHP_EOL; } @@ -237,6 +215,10 @@ EOF; } + /* + * Function: pset + * Set a value for param, deleteit if null + */ function pset($name,$value) { if ($value === null) { unset ($_REQUEST[$name]); @@ -315,8 +297,8 @@ a.attname AS name, pg_catalog.format_type(a.atttypid, a.atttypmod) AS type, CASE a.attnotnull WHEN 't' then 1 ELSE 0 END AS notnull, (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef) AS default, -(SELECT 1 FROM pg_index i WHERE a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) AND i.indrelid = 'tickets'::regclass AND i.indisprimary) as pk -FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname='tickets' AND pg_catalog.pg_table_is_visible(c.oid) ) AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum"; +(SELECT 1 FROM pg_index i WHERE a.attrelid = i.indrelid AND a.attnum = ANY(i.indkey) AND i.indrelid = '$this->name'::regclass AND i.indisprimary) as pk +FROM pg_catalog.pg_attribute a WHERE a.attrelid = (SELECT c.oid FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relname='$this->name' AND pg_catalog.pg_table_is_visible(c.oid) ) AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum"; } elseif ($this->db->type == 'mysql') { $sql = "SHOW COLUMNS FROM `$this->name`";