Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#109 xmlschema opt flag not working for mysqlt

open
nobody
None
5
2009-10-27
2009-10-27
OpenNetAdmin
No

I'm able to get the following XML statement to function when using a platform of "mysql". If I use a platform of "mysqlt" it does everything but the option section that sets the database storage type. I have not looked at the code but I assume it is simply ignored for some reason when using that database driver, and possibly others?

Thanks.

<table name="configuration_types">
<opt platform="mysqlt">TYPE=INNODB</opt>
<field name="id" type="I" size="10">
<KEY/>
<UNSIGNED/>
</field>
<field name="name" type="C" size="63">
<NOTNULL/>
</field>
</table>

Discussion

  • Paul Kirby
    Paul Kirby
    2009-11-13

    Ok a quick fix that got it working for me was the following in adodb-xmlschema03.inc.php:

    change from the following:
    function addTableOpt( $opt ) {
    if(isset($this->currentPlatform)) {
    $this->opts[$this->parent->db->databaseType] = $opt;
    }
    return $this->opts;
    }

    to:
    function addTableOpt( $opt ) {
    if(isset($this->currentPlatform)) {
    $this->opts[$this->parent->db->dataProvider] = $opt;
    }
    return $this->opts;
    }

    Or maybe the following, both worked for me:

    function addTableOpt( $opt ) {
    if(isset($this->currentPlatform)) {
    $this->opts[$this->parent->dict->databaseType] = $opt;
    }
    return $this->opts;
    }

    The cause was due to the writing and reading location for the options are both different when using mysqli or mysqlt both try and read it as if it was using mysql.
    Anyway as I have said either one of the above fixes worked for me, worth a try.

     
  • Paul Kirby
    Paul Kirby
    2009-11-13

    If you don't want to alter ADOdb's code you can use the following in your code to resolve this issue.
    This is what I have decided on doing right after my last message, doing it this way will save you in having to keep updating ADOdb every time a new version comes out that hasn't fixed this.
    Anyway i have added a switch where you can switch the hack on or off.

    Just change following to suit your code.

    // Switch to turn the hack on or off.
    if( !defined( 'MYSQLT_HACK' ) ) {
    define( 'MYSQLT_HACK', TRUE );
    }

    // Set Database Type
    $db_type = "mysqlt";

    // Setting up database connection.
    $db = ADONewConnection($db_type);
    ...
    ...
    ...

    // How ever you setup the schema.
    $schema = new adoSchema($db);
    $schema->setPrefix($db->prefix);

    // Hack to get mysqlt and mysqli (Set db_type to either "mysqli" or "mysqlt" or even "mysql")
    if (MYSQLT_HACK) {
    $schema->dict->upperName = strtoupper($db_type);
    }

    // Now your ready to do some schema stuff.

    Hope that helps you out.