WURFL

May 29, 2007

The WURFL is an XML configuration file which contains information about capabilities and features of many mobile devices: http://wurfl.sourceforge.net/index.php


PEAR: No handlers error

May 17, 2007

When running PEAR manager to install a package (eg, ./pear install Log), if you encounter this error “No handlers for package.xml version 2.0″, it means your PEAR needs upgrading.

The command to upgrade PEAR:

./pear upgrade PEAR

When upgrading PEAR, you might be prompted to upgrade some other dependencies (such as Archive_Tar):

./pear upgrade Archive_Tar


Alter MySQL table engine type

May 15, 2007
Alter table t1 TYPE = InnoDB;


MySQL 5 data types

May 9, 2007

Explanation of the various data types in MySQL 5: http://dev.mysql.com/doc/refman/5.0/en/data-types.html


Reset MySQL auto_increment

May 7, 2007
ALTER TABLE mytable AUTO_INCREMENT = 8;

    This sets the auto_increment ID to start from either 8 or its current value, whichever is higher.


    Template for PHP MySQL queries

    May 7, 2007

    <?
    $link = mysql_connect(’localhost’, ‘root’, ‘password’);
    if (!$link) {
    die(’Could not connect: ‘ . mysql_error());
    }

    $db_selected = mysql_select_db(’jsfbasic’, $link);

    $result = mysql_query(’SELECT * FROM recipe’, $link);

    if (!$result) {
    die(’Invalid query: ‘ . mysql_error());
    }

    while ($row = mysql_fetch_array($result)) {
    echo $row[0] . ‘<br />’;
    }

    mysql_close($link);
    ?>


    Last inserted ID in MySQL

    May 6, 2007

    To retrieve the last inserted ID of the auto_increment column:

    mysql> select last_insert_id();

    The PHP equivalent is:

    mysql_insert_id

    The above must be invoked from the same thread that performed the insertion.