<?php
// Modification log
// (date)       (author)    (activity/purpose)
//
// Todo
// (date)       (author)    (activity/purpose)
// 12.09.04     T Gildseth  Implement
// 12.09.04     T Gildseth  Come up with a better name for the pkValue() method.

/**
 * A DBTableInfo helper class, implementing database specific methods.
 *
 * @author Tommy Gildseth <tommy@akili.no>;
 * @copyright Tommy Gildseth, September 2004
 * @version 0.0.1
 * @access private
 * @package DBTableInfo
 */
class DBTIMysql {

    
//{{{ DBTIMysql(flags)
    /**
     * Extract information about a column, from the string contained in $flags
     *
     * @param string    $flags  column flags as returned by the
     *                          DB_Common::tableInfo() function
     * @access public
     */
    
function parseFlags($flags) {
        return new 
DBTIError(DBTI_UNSUPORTED_DATABASE);
        
$flags explode(' 'urldecode($flags));

        
$return = array('primaryKey' => false,
                        
'required' => false,
                        
'default' => false);
        foreach(
$flags as $flag) {
            switch(
$flag) {
                case 
'not_null':
                    
$return['required'] = true;
                    break;
                case 
'primary_key':
                    
$return['primaryKey'] = true;
                    break;
                default:
                    if (
stristr($flag'nextval')) {
                        
preg_match('/\(.*\)/'$flag$matches);
                        
$return['sequence'] = str_replace(array('('')'), ''$matches[0]);
                        
$return['default'] = 'sequence';
                    } else if (
stristr($flag'default')) {
                        
$return['default'] = str_replace('default_'''$flag);
                    }
            }
        }
    return 
$return;
    } 
// }}} end parseFlags


    //{{{ pkValue(pearDB, flags)
    /**
     * Find the value of the most recently inserted value in a auto_increment column
     *
     * @param object    $pearDB An instance of the PEAR DB class.
     * @param array     $flags  column flags for all the columns in the table
     * @access public
     */
    
function pkValue(&$pearDB$flags) {
        return 
mysql_insert_id();
    } 
// }}} end parseFlags
}
?>