Пример #1
0
		/** Returns a full list of tables in an array. */
		function getTables(){
			if ($this->getConn()){
				$return = array();
				
				if ($this->getType() == "mysql"){
					$f_gt = $this->query("SHOW TABLE STATUS", $this->conn);
					while($d_gt = $this->query_fetch_assoc($f_gt)){
						$return[] = array(
							"name" => $d_gt[Name],
							"engine" => $d_gt[Engine],
							"collation" => $d_gt[Collation],
							"rows" => $d_gt[Rows]
						);
					}
					
					return $return;
				}elseif($this->getType() == "pgsql"){
					$f_gt = $this->query("SELECT relname FROM pg_stat_user_tables ORDER BY relname");
					while($d_gt = $this->query_fetch_assoc($f_gt)){
						$return[] = array(
							"name" => $d_gt[relname],
							"engine" => "pgsql",
							"collation" => "pgsql"
						);
					}
					
					return $return;
				}elseif($this->getType() == "sqlite" || $this->getType() == "sqlite3"){
					$f_gt = $this->query("SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name");
					while($d_gt = $this->query_fetch_assoc($f_gt)){
						if ($d_gt["name"] != "sqlite_sequence"){
							$return[] = array(
								"name" => $d_gt[name],
								"engine" => "sqlite",
								"collation" => "sqlite"
							);
						}
					}
					
					return $return;
				}elseif($this->getType() == "access"){
					$f_gt = odbc_tables($this->conn);
					while($d_gt = odbc_fetch_array($f_gt)){
						if ($d_gt[TABLE_TYPE] == "TABLE"){
							$return[] = array(
								"name" => $d_gt[TABLE_NAME],
								"engine" => "access",
								"collation" => "access"
							);
						}
					}
					
					return $return;
				}else{
					throw new Exception("Not a valid type: " . $this->getType());
				}
			}
		}
Пример #2
0
function db_gettablelist()
{
	global $conn;
	$ret=array();
	$rs = odbc_tables($conn);
	while(odbc_fetch_row($rs))
		if(odbc_result($rs,"TABLE_TYPE")=="TABLE" || odbc_result($rs,"TABLE_TYPE")=="VIEW")
			$ret[]=odbc_result($rs,"TABLE_NAME");
	return $ret;
}
Пример #3
0
 /**
  * @return Array
  */
 public function db_gettablelist()
 {
     $ret = array();
     $rs = odbc_tables($this->connectionObj->conn);
     while (odbc_fetch_row($rs)) {
         if (odbc_result($rs, "TABLE_TYPE") == "TABLE" || odbc_result($rs, "TABLE_TYPE") == "VIEW") {
             $ret[] = odbc_result($rs, "TABLE_NAME");
         }
     }
     return $ret;
 }
Пример #4
0
 /**
  * @see DatabaseInfo::initTables()
  */
 protected function initTables()
 {
     include_once 'creole/drivers/odbc/metadata/ODBCTableInfo.php';
     $result = @odbc_tables($this->conn->getResource());
     if (!$result) {
         throw new SQLException('Could not list tables', $this->conn->nativeError());
     }
     while (odbc_fetch_row($result)) {
         $tablename = strtoupper(odbc_result($result, 'TABLE_NAME'));
         $this->tables[$tablename] = new ODBCTableInfo($this, $tablename);
     }
     @odbc_free_result($result);
 }
Пример #5
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;
 }
Пример #6
0
 function afficheTables($pFichAction)
 {
     //remplissage de la liste
     $tablelist = odbc_tables($this->connexion);
     echo '<form name="choixTables" method="get" action="' . $pFichAction . '">';
     echo '<select name="lesTables">';
     while (odbc_fetch_row($tablelist)) {
         if (odbc_result($tablelist, 4) == "TABLE") {
             // Si l'objet en cours a pour indicateur TABLE                //test à ajouter dans la condition pour ne pas afficher les  tables système en Access     && !(substr(odbc_result($tablelist,3),0,4)=="MSys")
             echo '<option value="' . odbc_result($tablelist, 3) . '">' . odbc_result($tablelist, 3) . '</option>';
         }
         // Affiche nom de la TABLE
     }
     echo '</select><input type="submit" value="Afficher"></input></form>';
 }
Пример #7
0
 /**
  * Retorna un array con las tablas accesibles por el ODBC. Cada array tiene los encabezados
  * KEY => VALUE y los key son las constantes TABLE_*
  */
 public function getTables()
 {
     $tables = array();
     if ($this->_isConnected()) {
         $result = odbc_tables($this->conn);
         if (!$result) {
             $this->_error = "No fue posible consultar las respuestas";
             return null;
         }
         while ($row = odbc_fetch_array($result)) {
             $tables[] = $row;
         }
     } else {
         $this->_error = "No se encuentra conectado a ningun ODBC";
         return null;
     }
     return $tables;
 }
 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;
 }
Пример #9
0
            print "<p>Uh-oh! Failure to connect to DSN [{$DSN}]: <br />";
            odbc_errormsg();
        } else {
            print "done</p>\n";
            $resultset = odbc_exec($handle, "{$query}");
            odbc_result_all($resultset, "border=2");
            odbc_close($handle);
        }
    } else {
        print "<p>Sorry, that query has been disabled for security reasons</p>\n";
    }
}
if ($listtables != NULL) {
    print "<h2>List of tables</h2>";
    print "<p>Connecting... ";
    $handle = odbc_connect("{$DSN}", "{$uid}", "{$passwd}");
    print "done</p>\n";
    if (!$handle) {
        print "<p>Uh-oh! Failure to connect to DSN [{$DSN}]: <br />";
        odbc_errormsg();
    } else {
        $resultset = odbc_tables($handle);
        odbc_result_all($resultset, "border=2");
        odbc_close($handle);
    }
}
?>

</body>
</html>
Пример #10
0
<?php

$result = odbc_tables($connection);
$first = isset($_POST['first']) ? $_POST['first'] : 0;
if (isset($_POST['rows'])) {
    $max = $_POST['rows'];
}
if ($result) {
    echo "\"data\":[";
    $j = 0;
    // For some reason odbc_fetch_array ignores the second parameter
    while ($first >= 0) {
        $data = odbc_fetch_array($result);
        $first--;
    }
    while ($data) {
        echo json_encode($data);
        $j++;
        if (!(isset($max) && $j >= $max)) {
            $data = odbc_fetch_array($result);
        } else {
            $data = false;
        }
        if ($data) {
            echo ",";
        }
    }
    echo "],";
}
echo "\"totalRecords\":" . $j . ",";
$status = "ok";
Пример #11
0
 /**
  * Returns an array of sources (tables) in the database.
  *
  * @return array Array of tablenames in the database
  */
 function listSources()
 {
     $cache = parent::listSources();
     if ($cache != null) {
         return $cache;
     }
     /*$result = odbc_tables($this->connection);
     		if (function_exists('odbc_fetch_row')) {
     			echo 'GOOD';
     		} else {
     			echo 'BAD';
     		}*/
     $result = odbc_tables($this->connection);
     $tables = array();
     while (odbc_fetch_row($result)) {
         array_push($tables, odbc_result($result, "TABLE_NAME"));
     }
     parent::listSources($tables);
     return $tables;
 }
Пример #12
0
 /**
  * Description
  *
  * @access	public
  * @return array A list of all the tables in the database
  */
 function getTableList()
 {
     return odbc_tables($this->_resource);
 }
Пример #13
0
}
function cmp($arr1, $arr2)
{
    $a = $arr1[1];
    /* count of cols in 1st array */
    $b = $arr2[1];
    /* count of cols in 2nd array */
    if ($a == $b) {
        return 0;
    }
    return $a < $b ? -1 : 1;
}
prepare_conversion();
$table_names = array();
$tables = array();
$r = odbc_tables($conn);
while ($t = odbc_fetch_array($r)) {
    //    print_r($t);
    $type = $t['TABLE_TYPE'] == 'TABLE';
    $owner = true;
    if (isset($t['TABLE_OWNER'])) {
        $owner = strtolower($t['TABLE_OWNER']) != 'information_schema';
    }
    if ($type && $owner) {
        $table_names[] = $t['TABLE_NAME'];
    }
}
for ($i = 0; $i < count($table_names); $i++) {
    $cols = get_cols($conn, $table_names[$i]);
    $cnt = count($cols);
    $tables[] = array($cols, $cnt, $table_names[$i]);
Пример #14
0
 */
$odbc['dsn'] = "SageLine50v19";
// pointing to C:\Documents and Settings\All Users\Application Data\Sage\Accounts\2013\Demodata\ACCDATA
//$odbc['dsn'] = "sagedemo";
$odbc['user'] = "******";
$odbc['pass'] = "";
// Step 1: Connect to the source ODBC database
if ($debug) {
    echo "Connect to " . $odbc['dsn'] . ' as ' . $odbc['user'] . "\n";
}
$conn = odbc_connect($odbc['dsn'], $odbc['user'], $odbc['pass']);
if (!$conn) {
    die("Error connecting to the ODBC database: " . odbc_errormsg());
}
// loop through each table
$allTables = odbc_tables($conn);
$tablesArray = array();
while (odbc_fetch_row($allTables)) {
    if (odbc_result($allTables, "TABLE_TYPE") == "TABLE") {
        $tablesArray[] = odbc_result($allTables, "TABLE_NAME");
    }
}
//print_r($tablesArray);      // to list all tables
if (!empty($tablesArray)) {
    // loop though each table
    foreach ($tablesArray as $currentTable) {
        echo "Table " . $currentTable;
        // get first, or all entries in the table.
        if ($debug) {
            echo $currentTable;
        }
Пример #15
0
<html>
<head>
<title>ezRETS Metadata Viewer with PHP</title>
</head>
<body>
About to make a connection.<br/>
<?php 
$dsn = "retstest";
$user = "******";
$pwd = "Schmoe";
$conn = odbc_connect($dsn, $user, $pwd);
?>
Connection made.<br/>
<?php 
// lookup tables
$tableexec = odbc_tables($conn);
$table_count = odbc_num_fields($tableexec);
echo "There are {$table_count} tables on the server</br>";
?>
<table border="0" width="100%" cellpadding="10" cellspacing="0">
<?php 
// loop through tables
while (odbc_fetch_row($tableexec)) {
    ?>
  <tr>
    <td>
      <table border=\"1\">
        <tr bgcolor="yellow">
          <th>Table Name</th><th>Description</th><th>Columns</th>
        </tr>
        <tr>
Пример #16
0
 /**
  * Returns list of tables.
  * @return array
  */
 public function getTables()
 {
     $result = odbc_tables($this->connection);
     $res = array();
     while ($row = odbc_fetch_array($result)) {
         if ($row['TABLE_TYPE'] === 'TABLE' || $row['TABLE_TYPE'] === 'VIEW') {
             $res[] = array('name' => $row['TABLE_NAME'], 'view' => $row['TABLE_TYPE'] === 'VIEW');
         }
     }
     odbc_free_result($result);
     return $res;
 }
Пример #17
0
 /**
  * Obtains the query string needed for listing a given type of objects
  *
  * Thanks to symbol1@gmail.com and Philippe.Jausions@11abacus.com.
  *
  * @param string $type  the kind of objects you want to retrieve
  *
  * @return string  the list of objects requested
  *
  * @access protected
  * @see DB_common::getListOf()
  * @since Method available since Release 1.7.0
  */
 function getSpecialQuery($type)
 {
     switch ($type) {
         case 'databases':
             if (!function_exists('odbc_data_source')) {
                 return null;
             }
             $res = @odbc_data_source($this->connection, SQL_FETCH_FIRST);
             if (is_array($res)) {
                 $out = array($res['server']);
                 while ($res = @odbc_data_source($this->connection, SQL_FETCH_NEXT)) {
                     $out[] = $res['server'];
                 }
                 return $out;
             } else {
                 return $this->odbcRaiseError();
             }
             break;
         case 'tables':
         case 'schema.tables':
             $keep = 'TABLE';
             break;
         case 'views':
             $keep = 'VIEW';
             break;
         default:
             return null;
     }
     /*
      * Removing non-conforming items in the while loop rather than
      * in the odbc_tables() call because some backends choke on this:
      *     odbc_tables($this->connection, '', '', '', 'TABLE')
      */
     $res = @odbc_tables($this->connection);
     if (!$res) {
         return $this->odbcRaiseError();
     }
     $out = array();
     while ($row = odbc_fetch_array($res)) {
         if ($row['TABLE_TYPE'] != $keep) {
             continue;
         }
         if ($type == 'schema.tables') {
             $out[] = $row['TABLE_SCHEM'] . '.' . $row['TABLE_NAME'];
         } else {
             $out[] = $row['TABLE_NAME'];
         }
     }
     return $out;
 }
Пример #18
0
getResultResource(){return$this->resultSet;}function
getTables(){$res=odbc_tables($this->connection);$tables=array();while($row=odbc_fetch_array($res)){if($row['TABLE_TYPE']==='TABLE'||$row['TABLE_TYPE']==='VIEW'){$tables[]=array('name'=>$row['TABLE_NAME'],'view'=>$row['TABLE_TYPE']==='VIEW');}}odbc_free_result($res);return$tables;}function
Пример #19
0
 function DoExecute()
 {
     //parent::DoExecute();
     $this->Result = odbc_tables($this->Db->Connection);
 }
Пример #20
0
 /**
  * 
  */
 public function listTables()
 {
     $result = odbc_tables($this->_connection);
     //                or die("Error :".odbc_errormsg());
     $tables = array();
     try {
         while (odbc_fetch_row($result)) {
             if (odbc_result($result, "TABLE_TYPE") == "TABLE") {
                 $tables[] = odbc_result($result, "TABLE_NAME");
             }
         }
     } catch (Exception $e) {
         if ($this->debug) {
             echo $e->getCode() . ' ' . $e->getMessage();
         }
     }
     return $tables;
 }
Пример #21
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) {
         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;
 }
Пример #22
0
 /**
  * Return a ResultSet with all the table names from the database of the query.
  *
  * @param object sqlConnect $dbc
  * @return ResultSet $result  ResultSet with all the tables names
  * @access public
  * @see fetchTableName()
  */
 function getTables($dbc = 0)
 {
     if ($dbc == 0) {
         $dbc = $this->getDbCon();
     }
     $result = odbc_tables($dbc->id);
     $this->result = $result;
     $this->cursor = 0;
     $this->num_rows = odbc_num_rows($result);
     return $result;
 }
Пример #23
0
 function MetaColumns($table)
 {
     global $ADODB_FETCH_MODE;
     $table = strtoupper($table);
     $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), '%');
     } else {
         if ($this->databaseType == 'access') {
             $qid = odbc_columns($this->_connectionID);
         } else {
             $qid = odbc_columns($this->_connectionID, '%', '%', strtoupper($table), '%');
         }
     }
     $rs = new ADORecordSet_odbc($qid);
     $ADODB_FETCH_MODE = $savem;
     if (!$rs) {
         return false;
     }
     //print_r($rs);
     $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) {
         //print_r($rs->fields);
         if (strtoupper($rs->fields[2]) == $table) {
             $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]);
             $retarr[strtoupper($fld->name)] = $fld;
         } else {
             if (sizeof($retarr) > 0) {
                 break;
             }
         }
         $rs->MoveNext();
     }
     $rs->Close();
     //-- crashes 4.03pl1 -- why?
     return $retarr;
 }
Пример #24
0
 function getTables()
 {
     $this->result = odbc_tables($this->db);
     if ($this->result) {
         foreach ($this->getAll() as $entry) {
             if ($entry['TABLE_TYPE'] != 'SYSTEM TABLE') {
                 $res[] = $entry['TABLE_NAME'];
             }
         }
     } else {
         $this->_addError(odbc_errormsg($this->db), "getTables");
     }
     return @$res;
 }
Пример #25
0
function list_tables()
{
    global $dsn, $dbConn;
    open_db();
    $tabs = odbc_tables($dbConn);
    $tables = array();
    echo '<table border="1" cellpadding="10">';
    echo '<thead>';
    echo '<tr>';
    echo '<th> Table </th>';
    echo '<th colspan="4"> Action </th>';
    echo '</tr>';
    echo '</thead>';
    echo '<tbody>';
    while (odbc_fetch_row($tabs)) {
        if (odbc_result($tabs, "TABLE_TYPE") == "TABLE") {
            $table_name = odbc_result($tabs, "TABLE_NAME");
            echo '<tr>';
            echo '<td>' . $table_name . '</td>';
            echo '<td width="20"> <a href="list.php?table=' . $table_name . '"> List </a> </td>';
            echo '<td width="20"> <a href="new.php?table=' . $table_name . '"> Add </a> </td>';
            echo '</tr>';
        }
    }
    echo '</tbody>';
    echo '</table>';
    close_db();
    return true;
}
Пример #26
0
function querY($type, $host, $user, $pass, $db = '', $query)
{
    $res = '';
    switch ($type) {
        case 'MySQL':
            if (!checkfunctioN('mysql_connect')) {
                return 0;
            }
            $link = mysql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mysql_select_db($db, $link);
                }
                $result = mysql_query($query, $link);
                while ($data = mysql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mysql_num_fields($result); $i++) {
                    $res .= mysql_field_name($result, $i) . '[-][-][-]';
                }
                mysql_close($link);
                return $res;
            }
            break;
        case 'MSSQL':
            if (!checkfunctioN('mssql_connect')) {
                return 0;
            }
            $link = mssql_connect($host, $user, $pass);
            if ($link) {
                if (!empty($db)) {
                    mssql_select_db($db, $link);
                }
                $result = mssql_query($query, $link);
                while ($data = mssql_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < mssql_num_fields($result); $i++) {
                    $res .= mssql_field_name($result, $i) . '[-][-][-]';
                }
                mssql_close($link);
                return $res;
            }
            break;
        case 'ODBC':
            if (!checkfunctioN('odbc_connect')) {
                return 0;
            }
            $link = odbc_connect($host, $user, $pass);
            if ($link) {
                if (strstr(trim(strtoupper($query)), 'SHOW TABLES') != false) {
                    $result = odbc_tables($link);
                } else {
                    $result = odbc_exec($link, $query);
                }
                while ($data = odbc_fetch_array($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 1; $i < odbc_num_fields($result); $i++) {
                    $res .= odbc_field_name($result, $i) . '[-][-][-]';
                }
                odbc_close($link);
                return $res;
            }
            break;
        case 'Oracle':
            if (!checkfunctioN('ocilogon')) {
                return 0;
            }
            $link = oci_connect($user, $pass, $db);
            if ($link) {
                $stm = ociparse($link, $query);
                ociexecute($stm, OCI_DEFAULT);
                while ($data = ocifetchinto($stm, $data, OCI_ASSOC + OCI_RETURN_NULLS)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < oci_num_fields($stm); $i++) {
                    $res .= oci_field_name($stm, $i) . '[-][-][-]';
                }
                return $res;
            }
            break;
        case 'PostgreSQL':
            if (!checkfunctioN('pg_connect')) {
                return 0;
            }
            $link = pg_connect("host={$host} dbname={$db} user={$user} password={$pass}");
            if ($link) {
                $result = pg_query($link, $query);
                while ($data = pg_fetch_row($result)) {
                    $res .= implode('|-|-|-|-|-|', $data) . '|+|+|+|+|+|';
                }
                $res .= '[+][+][+]';
                for ($i = 0; $i < pg_num_fields($result); $i++) {
                    $res .= pg_field_name($result, $i) . '[-][-][-]';
                }
                pg_close($link);
                return $res;
            }
            break;
    }
    return 0;
}
Пример #27
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;
 }
Пример #28
0
<?php

include 'config.inc';
$conn = odbc_connect($dsn, $user, $pass);
var_dump($result = odbc_tables($conn, '', '', '', ''));
var_dump(odbc_fetch_row($result));
var_dump($result = odbc_tables($conn, NULL, NULL, NULL, NULL));
var_dump(odbc_fetch_row($result));
var_dump($result = odbc_tables($conn, 'FOO', 'FOO', 'FOO', 'FOO'));
var_dump(odbc_fetch_row($result));
Пример #29
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;
 }
Пример #30
0
 /**
  * Returns an array of sources (tables) in the database.
  *
  * @return array Array of tablenames in the database
  */
 function listSources()
 {
     $cache = parent::listSources();
     if ($cache != null) {
         return $cache;
     }
     $result = odbc_tables($this->connection);
     $tables = array();
     while (odbc_fetch_row($result)) {
         array_push($tables, odbc_result($result, 'TABLE_NAME'));
     }
     parent::listSources($tables);
     return $tables;
 }