function __construct($dbName, $tablName, $indx, $displayText, $ar_subset, $rw)
 {
     global $allDBConns;
     echo "<!-- Constructing {$tablName} -->\n";
     $this->dbName = $dbName;
     if (!$allDBConns) {
         $allDBConns = new DBConnManager();
     }
     $this->dbConn = $allDBConns->getConn($this->dbName, $rw);
     $tabl = $tablName;
     $this->tabl = $tabl;
     $r = $this->xQuery("SELECT * FROM {$tabl} LIMIT 1;", 0);
     $ar = pg_fetch_assoc($r);
     pg_free_result($r);
     if (!$ar) {
         echo "<p><strong>Warning: database may need ", "intializing</strong></p>\n";
     }
     $this->colNames = array_keys($ar);
     if ($indx and !in_array($indx, $this->colNames)) {
         $indx = '';
     }
     if (!$indx) {
         echo "<p> Index (", $this->getIndx(), ") not found <br />\n";
         print_r($this->colNames);
         echo "</p>\n";
     }
     $this->indx = $indx;
     if (in_array('obid', $this->colNames) and in_array('active', $this->colNames)) {
         $wiki = 1;
     } else {
         $wiki = 0;
     }
     $this->useWiki = $wiki;
     if ($this->useWiki) {
         $this->colNames = array_diff($this->colNames, array('obid', 'active', 'lastdate'));
     }
     $this->ar_subset = $ar_subset;
     $this->itemInfo = $this->buildInfo();
     //echo "<p>display = $displayText</p>\n";
     if ($p = strpos($displayText, ' AS ')) {
         //echo "<p>parsing display...</p>\n";
         $this->displayQuery = substr($displayText, 0, $p);
         $this->displayText = substr($displayText, $p + 4);
     } elseif (strpos($displayText, ',')) {
         $this->displayQuery = $this->buildDisplayQuery($displayText);
         $this->displayText = '_display';
     } else {
         $this->displayQuery = '';
         $this->displayText = $displayText;
     }
     $this->arTextFlds = array();
     $this->formid = '';
     $this->itemInfo = $this->buildInfo();
     $this->xQueryInfo = array();
     $this->includedTablAr = array();
     echo "<!-- {$tablName} constructed -->\n";
 }
 function __construct($tabl, $indx, $useWiki, $dbName)
 {
     global $allDBConns;
     $this->dbName = $dbName;
     if (!$allDBConns) {
         $allDBConns = new DBConnManager();
     }
     $this->dbConn = $allDBConns->getConn($this->dbName);
     $this->tabl = $tabl;
     $r = $this->xQuery("SELECT c.column_name FROM information_schema.columns c " . "WHERE c.table_name='{$tabl}';", 0);
     $this->colNames = pg_fetch_all_columns($r, 0);
     if ($indx and !in_array($indx, $this->colNames)) {
         $indx = '';
     }
     $this->indx = $indx;
     $this->useWiki = $useWiki;
     if ($useWiki) {
         $this->colNames = array_diff($this->colNames, array('obid', 'active', 'lastdate'));
     }
 }