Inside: dml.mysqli.class.inc
function ddl_showTables ($dbname)
// obtain a list of tables within the specified database.
{
// connect to database
$this->connect($dbname) or trigger_error($this, E_USER_ERROR);
$array = array();
$dbname = $GLOBALS['dbprefix'] .$dbname;
// build the query string and run it
$this->query = 'SHOW TABLES FROM "' .$dbname .'"';
$result = mysqli_query($this->dbconnect, $this->query) or trigger_error($this, E_USER_ERROR);
$count = mysqli_num_rows($result);
// write query to log file, if option is turned on
logSqlQuery ($dbname, null, $this->query, $count);
// convert result set into a simple indexed array for each row
while ($row = mysqli_fetch_row($result)) {
$array[] = $row[0];
} // while
mysqli_free_result($result);
return $array;
} // ddl_showTables
Notice the $dbname variable gets reassigned to:
$dbname = $GLOBAL['dbprefix'] . $dbname;
When it comes into this function it already has the dbprefix attached to it from the _cm_getInitialDataMultiple function of dict_table_s01.class.inc. (Noted below).
function _cm_getInitialDataMultiple ($fieldarray)
// Perform custom processing prior to insertMultiple.
// $fieldarray contains data from the initial $where clause.
{
// get list of existing table names
if (!is_string(key($fieldarray))) {
$fieldarray = $fieldarray[0];
} // if
$dbname = $fieldarray['database_id'];
$dbprefix = dict_findDBPrefix($dbname);
$array = $this->_ddl_showTables($dbprefix.$dbname);
// filter out those that already exist in DICT database
$i = 0;
foreach ($array as $tablename) {
$tablename = strtolower($tablename);
$count = $this->getCount("database_id='$dbname' AND table_id='$tablename'");
if ($count == 0) {
// insert details of new database
$fieldarray[$i]['database_id'] = $dbname;
$fieldarray[$i]['table_id'] = $tablename;
$fieldarray[$i]['table_desc'] = ucwords(str_replace('_', ' ', $tablename));
$i++;
} // if
} // foreach
return $fieldarray;
} // _cm_getInitialDataMultiple
The call to $this->_ddl_showTables($dbprefix.$dbname); adds the prefix and then the call within Default_Table::_ddl_showTables that calls mysql::ddl_showTables does the same thing. Hence the double append.
Does that help?
Kyle Brost
----
www.softelephant.com