Home » RADICORE development » Bug Reports » Database/Table Import Error (BUG Report)
|
|
Re: Database/Table Import Error [message #2339 is a reply to message #2336] |
Fri, 06 November 2009 05:43   |
AJM
Messages: 2382 Registered: April 2006 Location: Surrey, UK
|
Senior Member |
|
|
I have tried this on my PC and I cannot reproduce the fault. It may be because of something in your config.inc file, so can you post me its contents? You can block out your username and password.
The way the $dbprefix feature is supposed to work is as follows:
- you have a database called 'foobar'
- it is imported into the data dictinary as 'foobar'
- you may create a copy of this database called 'dev1_foobar', but in order to access it your config.inc file should identify it as $dbname='foobar' and $dbprefix='dev1_'
- the dictionary import functions will use $dbprefix to access the database schema, but will use only $dbname within the dictionary database.
This means that you can have as may copies of 'foobar' as you like, such as 'dev1_foobar', 'dev2_foobar', 'this_foobar' and 'that_foobar', but the data dictionary will only have one set of details under the name 'foobar'. At runtime you can only access one of these databases, so you set the value of $dbprefix in your config.inc file accordingly.
If the dbname in the data dictionary includes the dbprefix then you have done something wrong.
I did find one small problem in the dict_table_key class, so I have attached an updated file.
|
|
|
|
|
|
|
Re: Database/Table Import Error [message #2345 is a reply to message #2344] |
Fri, 06 November 2009 13:42   |
ljkbrost
Messages: 59 Registered: April 2006
|
Member |
|
|
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
|
|
|
|
Goto Forum:
Current Time: Fri Jun 20 10:46:51 EDT 2025
Total time taken to generate the page: 0.01324 seconds
|