Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE development » Bug Reports » Database/Table Import Error (BUG Report)
Re: Database/Table Import Error [message #2345 is a reply to message #2344] Fri, 06 November 2009 13:42 Go to previous messageGo to previous message
ljkbrost is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Error messages not being returned to previous screen
Next Topic: std.update3.inc confusion
Goto Forum:
  


Current Time: Sun Nov 24 06:02:17 EST 2024

Total time taken to generate the page: 0.01021 seconds