Пример #1
0
 function &MetaTables()
 {
     $qid = odbc_tables($this->_connectionID);
     $rs = new ADORecordSet_odbc($qid);
     //print_r($rs);
     $arr =& $rs->GetArray();
     $arr2 = array();
     for ($i = 0; $i < sizeof($arr); $i++) {
         if ($arr[$i][2] && substr($arr[$i][2], 0, 4) != 'MSys') {
             $arr2[] = $arr[$i][2];
         }
     }
     return $arr2;
 }
 function &MetaTables()
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     $qid = odbc_tables($this->_connectionID);
     $rs = new ADORecordSet_odbc($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         return false;
     }
     $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
     $arr =& $rs->GetArray();
     $arr2 = array();
     for ($i = 0; $i < sizeof($arr); $i++) {
         if ($arr[$i][2] && substr($arr[$i][2], 0, 4) != 'MSys') {
             $arr2[] = $arr[$i][2];
         }
     }
     return $arr2;
 }
Пример #3
0
 function MetaTables($ttype = false, $showSchema = false, $qtable = "%", $qschema = "%")
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     $qid = odbc_tables($this->_connectionID, "", $qschema, $qtable, "");
     $rs = new ADORecordSet_odbc($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         $false = false;
         return $false;
     }
     $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
     $arr = $rs->GetArray();
     //print_r($arr);
     $rs->Close();
     $arr2 = array();
     if ($ttype) {
         $isview = strncmp($ttype, 'V', 1) === 0;
     }
     for ($i = 0; $i < sizeof($arr); $i++) {
         if (!$arr[$i][2]) {
             continue;
         }
         if (strncmp($arr[$i][1], 'SYS', 3) === 0) {
             continue;
         }
         $type = $arr[$i][3];
         if ($showSchema) {
             $arr[$i][2] = $arr[$i][1] . '.' . $arr[$i][2];
         }
         if ($ttype) {
             if ($isview) {
                 if (strncmp($type, 'V', 1) === 0) {
                     $arr2[] = $arr[$i][2];
                 }
             } else {
                 if (strncmp($type, 'T', 1) === 0) {
                     $arr2[] = $arr[$i][2];
                 }
             }
         } else {
             if (strncmp($type, 'S', 1) !== 0) {
                 $arr2[] = $arr[$i][2];
             }
         }
     }
     return $arr2;
 }
 function __construct($id, $mode = false)
 {
     return parent::__construct($id, $mode);
 }
Пример #5
0
 function &MetaTables($showSchema = false)
 {
     global $ADODB_FETCH_MODE;
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     $qid = odbc_tables($this->_connectionID);
     $rs = new ADORecordSet_odbc($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         return false;
     }
     $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
     //print_r($rs);
     $arr =& $rs->GetArray();
     $rs->Close();
     $arr2 = array();
     //print_r($arr);
     for ($i = 0; $i < sizeof($arr); $i++) {
         $row = $arr[$i];
         if ($row[2] && strncmp($row[1], 'SYS', 3) != 0) {
             if ($showSchema) {
                 $arr2[] = $row[1] . '.' . $row[2];
             } else {
                 $arr2[] = $row[2];
             }
         }
     }
     return $arr2;
 }
Пример #6
0
 function MetaColumns($table)
 {
     global $ADODB_FETCH_MODE;
     $false = false;
     if ($this->uCaseTables) {
         $table = strtoupper($table);
     }
     $schema = '';
     $this->_findschema($table, $schema);
     $savem = $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_NUM;
     /*if (false) { // after testing, confirmed that the following does not work becoz of a bug
     			$qid2 = odbc_tables($this->_connectionID);
     			$rs = new ADORecordSet_odbc($qid2);		
     			$ADODB_FETCH_MODE = $savem;
     			if (!$rs) return false;
     			$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
     			$rs->_fetch();
     			
     			while (!$rs->EOF) {
     				if ($table == strtoupper($rs->fields[2])) {
     					$q = $rs->fields[0];
     					$o = $rs->fields[1];
     					break;
     				}
     				$rs->MoveNext();
     			}
     			$rs->Close();
     			
     			$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
     		} */
     switch ($this->databaseType) {
         case 'access':
         case 'vfp':
             $qid = odbc_columns($this->_connectionID);
             #,'%','',strtoupper($table),'%');
             break;
         case 'db2':
             $colname = "%";
             $qid = odbc_columns($this->_connectionID, "", $schema, $table, $colname);
             break;
         default:
             $qid = @odbc_columns($this->_connectionID, '%', '%', strtoupper($table), '%');
             if (empty($qid)) {
                 $qid = odbc_columns($this->_connectionID);
             }
             break;
     }
     if (empty($qid)) {
         return $false;
     }
     $rs = new ADORecordSet_odbc($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         return $false;
     }
     $rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
     $rs->_fetch();
     $retarr = array();
     /*
     $rs->fields indices
     0 TABLE_QUALIFIER
     1 TABLE_SCHEM
     2 TABLE_NAME
     3 COLUMN_NAME
     4 DATA_TYPE
     5 TYPE_NAME
     6 PRECISION
     7 LENGTH
     8 SCALE
     9 RADIX
     10 NULLABLE
     11 REMARKS
     */
     while (!$rs->EOF) {
         //	adodb_pr($rs->fields);
         if (strtoupper(trim($rs->fields[2])) == $table && (!$schema || strtoupper($rs->fields[1]) == $schema)) {
             $fld = new ADOFieldObject();
             $fld->name = $rs->fields[3];
             $fld->type = $this->ODBCTypes($rs->fields[4]);
             // ref: http://msdn.microsoft.com/library/default.asp?url=/archive/en-us/dnaraccgen/html/msdn_odk.asp
             // access uses precision to store length for char/varchar
             if ($fld->type == 'C' or $fld->type == 'X') {
                 if ($this->databaseType == 'access') {
                     $fld->max_length = $rs->fields[6];
                 } else {
                     if ($rs->fields[4] <= -95) {
                         // UNICODE
                         $fld->max_length = $rs->fields[7] / 2;
                     } else {
                         $fld->max_length = $rs->fields[7];
                     }
                 }
             } else {
                 $fld->max_length = $rs->fields[7];
             }
             $fld->not_null = !empty($rs->fields[10]);
             $fld->scale = $rs->fields[8];
             $retarr[strtoupper($fld->name)] = $fld;
         } else {
             if (sizeof($retarr) > 0) {
                 break;
             }
         }
         $rs->MoveNext();
     }
     $rs->Close();
     //-- crashes 4.03pl1 -- why?
     if (empty($retarr)) {
         $retarr = false;
     }
     return $retarr;
 }
Пример #7
0
 function &MetaColumns($table)
 {
     $table = strtoupper($table);
     /* // for some reason, cannot view only 1 table with odbc_columns -- bug?
     		$qid = odbc_tables($this->_connectionID);
     		$rs = new ADORecordSet_odbc($qid);
     		if (!$rs) return false;
     		while (!$rs->EOF) {
     			if ($table == strtoupper($rs->fields[2])) {
     				$q = $rs->fields[0];
     				$o = $rs->fields[1];
     				break;
     			}
     			$rs->MoveNext();
     		}
     		$rs->Close();
     		
     		$qid = odbc_columns($this->_connectionID,$q,$o,strtoupper($table),'%');
     	*/
     $qid = odbc_columns($this->_connectionID);
     $rs = new ADORecordSet_odbc($qid);
     if (!$rs) {
         return false;
     }
     $retarr = array();
     while (!$rs->EOF) {
         if (strtoupper($rs->fields[2]) == $table) {
             $fld = new ADOFieldObject();
             $fld->name = $rs->fields[3];
             $fld->type = $this->ODBCTypes($rs->fields[4]);
             $fld->max_length = $rs->fields[7];
             $retarr[strtoupper($fld->name)] = $fld;
         } else {
             if (sizeof($retarr) > 0) {
                 break;
             }
         }
         $rs->MoveNext();
     }
     $rs->Close();
     //-- crashes 4.03pl1 -- why?
     return $retarr;
 }
Пример #8
0
	function &MetaTables($ttype=false)
	{
	global $ADODB_FETCH_MODE;
	
		$savem = $ADODB_FETCH_MODE;
		$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
		$qid = odbc_tables($this->_connectionID);
		
		$rs = new ADORecordSet_odbc($qid);
		
		$ADODB_FETCH_MODE = $savem;
		if (!$rs) {
			$false = false;
			return $false;
		}
		$rs->_has_stupid_odbc_fetch_api_change = $this->_has_stupid_odbc_fetch_api_change;
		
		$arr =& $rs->GetArray();
		//print_r($arr);
		
		$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;
	}