]> git.nbdom.net Git - nb.git/commitdiff
config dir
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 6 Jul 2015 16:33:14 +0000 (17:33 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 6 Jul 2015 16:33:14 +0000 (17:33 +0100)
lib/php/db.php

index 86b26f10ff8749b27a4d400d43420213eebaec18..11df63424a2180899ee9cf3787e0088ccd9d35dc 100644 (file)
@@ -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 .= '<option value="'.$table.'"';
-      #$pretty = prettyText($table);
       $r .= $table == $this->p('table') ? ' selected="selected"' : '';
       $r .= '>'.prettyText($table).'</option>'.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`";