Example #1
0
 /**
  * Db2 On I5 specific method
  *
  * Returns a list of the tables in the database .
  * Used only for DB2/400.
  *
  * @return array
  */
 protected function _i5listTables($schema = null)
 {
     //list of i5 libraries.
     $tables = array();
     if ($schema) {
         $tablesStatement = db2_tables($this->_connection, null, $schema);
         while ($rowTables = db2_fetch_assoc($tablesStatement)) {
             if ($rowTables['TABLE_NAME'] !== null) {
                 $tables[] = $rowTables['TABLE_NAME'];
             }
         }
     } else {
         $schemaStatement = db2_tables($this->_connection);
         while ($schema = db2_fetch_assoc($schemaStatement)) {
             if ($schema['TABLE_SCHEM'] !== null) {
                 // list of the tables which belongs to the selected library
                 $tablesStatement = db2_tables($this->_connection, NULL, $schema['TABLE_SCHEM']);
                 if (is_resource($tablesStatement)) {
                     while ($rowTables = db2_fetch_assoc($tablesStatement)) {
                         if ($rowTables['TABLE_NAME'] !== null) {
                             $tables[] = $rowTables['TABLE_NAME'];
                         }
                     }
                 }
             }
         }
     }
     return $tables;
 }
Example #2
0
 /**
  * Returns a list of the tables in the database.
  *
  * @return array
  */
 public function listTables()
 {
     $this->_connect();
     // take the most general case and assume no z/OS
     // since listTables() takes no parameters
     $stmt = db2_tables($this->_connection);
     $tables = array();
     while ($row = db2_fetch_assoc($stmt)) {
         $tables[] = $row['TABLE_NAME'];
     }
     return $tables;
 }
Example #3
0
 /**
  * Returns an array of all the tables in the database.
  * Should call parent::listSources twice in the method:
  * once to see if the list is cached, and once to cache
  * the list if not.
  *
  * @return array Array of tablenames in the database
  */
 function listSources()
 {
     $cache = parent::listSources();
     if ($cache != null) {
         return $cache;
     }
     $result = db2_tables($this->connection);
     $tables = array();
     while (db2_fetch_row($result)) {
         $tables[] = strtolower(db2_result($result, 'TABLE_NAME'));
     }
     parent::listSources($tables);
     return $tables;
 }
 function MetaTables($ttype = false, $schema = false)
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     $qid = db2_tables($this->_connectionID);
     $rs = new ADORecordSet_db2($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         $false = false;
         return $false;
     }
     $arr = $rs->GetArray();
     $rs->Close();
     $arr2 = array();
     //	adodb_pr($arr);
     if ($ttype) {
         $isview = strncmp($ttype, 'V', 1) === 0;
     }
     for ($i = 0; $i < sizeof($arr); $i++) {
         if (!$arr[$i][2]) {
             continue;
         }
         $type = $arr[$i][3];
         $schemaval = $schema ? $arr[$i][1] . '.' : '';
         $name = $schemaval . $arr[$i][2];
         $owner = $arr[$i][1];
         if (substr($name, 0, 8) == 'EXPLAIN_') {
             continue;
         }
         if ($ttype) {
             if ($isview) {
                 if (strncmp($type, 'V', 1) === 0) {
                     $arr2[] = $name;
                 }
             } else {
                 if (strncmp($type, 'T', 1) === 0 && strncmp($owner, 'SYS', 3) !== 0) {
                     $arr2[] = $name;
                 }
             }
         } else {
             if (strncmp($type, 'T', 1) === 0 && strncmp($owner, 'SYS', 3) !== 0) {
                 $arr2[] = $name;
             }
         }
     }
     return $arr2;
 }
Example #5
0
 function &MetaTables($ttype = false)
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     $qid = db2_tables($this->_connectionID);
     $rs = new ADORecordSet_db2($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         $false = false;
         return $false;
     }
     $arr =& $rs->GetArray();
     $rs->Close();
     $arr2 = array();
     if ($ttype) {
         $isview = strncmp($ttype, 'V', 1) === 0;
     }
     for ($i = 0; $i < sizeof($arr); $i++) {
         if (!$arr[$i][2]) {
             continue;
         }
         $type = $arr[$i][3];
         if ($ttype) {
             if ($isview) {
                 if (strncmp($type, 'V', 1) === 0) {
                     $arr2[] = $arr[$i][2];
                 }
             } else {
                 if (strncmp($type, 'SYS', 3) !== 0) {
                     $arr2[] = $arr[$i][2];
                 }
             }
         } else {
             if (strncmp($type, 'SYS', 3) !== 0) {
                 $arr2[] = $arr[$i][2];
             }
         }
     }
     return $arr2;
 }
 function MetaTables($ttype = false, $showSchema = false, $qtable = "%", $qschema = "%")
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     // @@@ original: $qid = db2_tables($this->_connectionID);
     $qid = db2_tables($this->_connectionID, null, $qschema, $qtable);
     $rs = new ADORecordSet_db2($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         $false = false;
         return $false;
     }
     $arr =& $rs->GetArray();
     $rs->Close();
     $arr2 = array();
     if ($ttype) {
         $isview = strncmp($ttype, 'V', 1) === 0;
     }
     for ($i = 0; $i < sizeof($arr); $i++) {
         if (!$arr[$i][2]) {
             continue;
         }
         $type = $arr[$i][3];
         // @@@ original: DB2/400 $schemaval = ($schema) ? $arr[$i][1].'.' : '';
         // use $showSchema instead of $schema, for consistency with odbc_db2.inc.php
         $schemaval = $showSchema ? $arr[$i][1] . '.' : '';
         if ($ttype) {
             if ($isview) {
                 if (strncmp($type, 'V', 1) === 0) {
                     $arr2[] = $schemaval . $arr[$i][2];
                 }
             } else {
                 if (strncmp($type, 'SYS', 3) !== 0) {
                     $arr2[] = $schemaval . $arr[$i][2];
                 }
             }
         } else {
             if (strncmp($type, 'SYS', 3) !== 0) {
                 $arr2[] = $schemaval . $arr[$i][2];
             }
         }
     }
     return $arr2;
 }
Example #7
0
 /**
  * @param string $table
  * @param string $schema
  * @param string $type
  * @return bool
  */
 protected function tableExistsExtended($table, $schema = '%', $type = 'TABLE')
 {
     $table = db2_tables($this->database, null, $schema, $table, $type);
     $table = $this->fetchByAssoc($table);
     return !empty($table);
 }
Example #8
0
 /**
  * Creates an array with all table names
  *
  * @return  void
  * @access  public
  * @author  Matteo Scaramuccia <*****@*****.**>
  * @author  Thorsten Rinne <*****@*****.**>
  * @since   2006-08-26
  */
 function getTableNames($prefix = '')
 {
     $stmt = db2_tables($this->conn);
     while ($table = db2_fetch_assoc($stmt)) {
         if ($table['TABLE_TYPE'] == 'TABLE' && strstr($table['TABLE_NAME'], $prefix . 'FAQ')) {
             $this->tableNames[] = $table['TABLE_NAME'];
         }
     }
 }
	function MetaTables($ttype=false,$schema=false)
	{
	global $ADODB_FETCH_MODE;

		$savem = $ADODB_FETCH_MODE;
		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
		$qid = db2_tables($this->_connectionID);

		$rs = new ADORecordSet_db2($qid);

		$ADODB_FETCH_MODE = $savem;
		if (!$rs) {
			$false = false;
			return $false;
		}

		$arr = $rs->GetArray();
		$rs->Close();
		$arr2 = array();

		if ($ttype) {
			$isview = strncmp($ttype,'V',1) === 0;
		}
		for ($i=0; $i < sizeof($arr); $i++) {
			if (!$arr[$i][2]) continue;
			$type = $arr[$i][3];
			$owner = $arr[$i][1];
			$schemaval = ($schema) ? $arr[$i][1].'.' : '';
			if ($ttype) {
				if ($isview) {
					if (strncmp($type,'V',1) === 0) $arr2[] = $schemaval.$arr[$i][2];
				} else if (strncmp($owner,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
			} else if (strncmp($owner,'SYS',3) !== 0) $arr2[] = $schemaval.$arr[$i][2];
		}
		return $arr2;
	}