Fork me on GitHub

Module upgrade - NewDataDictionary($dbconn);  Bottom

  • Is this available in .750?

    Code

    $dict = &NewDataDictionary($dbconn);

    // etc...etc...

    $sqlarray = $dict->AlterColumnSQL($Exampletable,$flds);


    ...or was it introduced in .760?
  • 760
  • Ah ok... But the old method is still viable for some time I assume?
  • Might be available in .750 - it's an adodb object...

    Old methods will always be available - they're part of adodb as well. But, using the method you quoted above ensures the SQL is compatible across all adodb supported databases

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Hello,
    I am not quite sure but I seem to remember that the only thing wich isn't available under .750 is the pnDBGetTableOptions API function,
    so as long as you don't write

    Code

    // Define any table specific options
        $taboptarray =& pnDBGetTableOptions();
       ... lines ommited here...
       $sqlarray = $dict->CreateTableSQL($table, $sql, $taboptarray);

    but use

    Code

    $sqlarray = $dict->CreateTableSQL($table, $sql, array('mysql' => 'type = MyISAM'));

    it should work. The third paramter specify option if database is Mysql but you don't loose other database compatibility.

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • Quote

    But of course you loose non Mysql compatibility.

    Code

    if(!function_exists(pnDBGetTableOptions))
    {
      // include file with own version of API
    }



    I'd work around it.

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • Opps HammerHead, you posted you answer while I was correcting my post. In fact the array('mysql' => 'type = MyISAM') parameter don't prevent other database compatibility because it is only used if database is mysql. I verified in AdoDB documentation.

    --
    Visit my live reef aquarium.

    My Amazon wish list.
  • That makes sense - but does adodb require information in the $tableopt array for other databases - meaning you couldn't hardcode the array to MySQL anyway?

    --
    itbegins.co.uk - Zikula Consulting

    birtwistle.me.uk - Personal Blog


    Please read the Support Guide
  • In fact no option are REQUIRED for any database.
    The adodb manual give the following exampes :

    Quote


    Database specific table options can be defined also using the name of the database type as the array key. In the following example, create the table as ISAM with MySQL, and store the table in the "users" tablespace if using Oracle. And because we specified REPLACE, drop the table first.

    $taboptarray = array('mysql' => 'TYPE=ISAM', 'oci8' => 'tablespace users', 'REPLACE');

    You can also define foreign key constraints. The following is syntax for postgresql:

    $taboptarray = array('constraints' => ', FOREIGN KEY (col1) REFERENCES reftable (refcol)');

    But as all the PostNuke users that I know of use MySql, I don't know if other databases require other options.
    the code in pmAPI is :

    Code

    /*
     * get a list of dbms specific table options
     *
     * For use by ADODB's data dictionary
     *
     * @author Mark West
     * @since v1.93
     */

    function &pnDBGetTableOptions()
    {
        // For mysql we should get the table type defined in config.php
        // Additional database specific settings can be defined here
        // See ADODB's data dictionary docs for full details
        // Since we'll use the same options for all tables we'll define this once
        return array('mysql' => 'type = ' . pnConfigGetVar('dbtabletype'));
    }

    and $pnconfig['dbtabletype'] is defined in config.php :

    Code

    $pnconfig['dbtabletype'] = 'MyISAM';

    Can anybody using Oracle or PostGres comment ? In my opinion the majority of PostNuke modules have queries that are only compatible with Mysql !!!

    --
    Visit my live reef aquarium.

    My Amazon wish list.

This list is based on users active over the last 60 minutes.