|
|
Fixed, however, used a different implementation. See below:
# --------------------
# Check if the specified table exists.
# @param $p_table_name Table name.
# @returns true: table found, false: table not found.
function db_table_exists( $p_table_name ) {
global $g_db, $g_db_schema;
if ( is_blank( $p_table_name ) ) {
return false; // no tables found
}
if ( db_is_db2() ) {
// must pass schema
$t_tables = $g_db->MetaTables( 'TABLE', false, '', $g_db_schema );
} else {
$t_tables = $g_db->MetaTables( 'TABLE' );
}
# Can't use in_array() since it is case sensitive
$t_table_name = strtolower( $p_table_name );
foreach ( $t_tables as $t_current_table ) {
if ( strtolower( $t_current_table ) == $t_table_name ) {
return true;
}
}
return false;
} |
|
|
Also in core/adodb/drivers/adodb-db2.inc.php:
Update the implementation of MetaTables based on the changes highlighted by @@@.
// @@@ original: function MetaTables($ttype=false,$schema=false)
// DB2/400 Allow table and schema as optional parameters.
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;
} |