< TIMESTAMP: Executing System Setting   (Previous) Table of Contents (Next)   TIMESTAMP: Formatting Query >

TIMESTAMP: Setting Query Format

/**
 * Sets the named property according to which DBMS is in use
 *
 * @return boolean  true if successful.  Does die() if the DBMS is unkown.
 */
function setTimestampQueryFormat() {
    switch ($this->phptype . ':' . $this->dbsyntax) {
        case 'fbsql:fbsql':
        case 'ibase:firebird':
        case 'mysql:mysql':
        case 'mysqli:mysqli':
        case 'oci8:oci8':
        case 'odbc:access':
        case 'pgsql:pgsql':
        case 'sqlite:sqlite':
            $this->TimestampQueryFormat = ' %s ';
            break;
        case 'mssql:mssql':
            $this->TimestampQueryFormat = ' CONVERT(CHAR(19), %s, 120) ';
            break;
        case 'odbc:db2':
            $this->TimestampQueryFormat = " TO_CHAR(%s, 'YYYY-MM-DD HH24:MI:SS') ";
            break;
        case 'sybase:sybase':
            $this->TimestampQueryFormat = ' STR_REPLACE('
                    . " CONVERT(CHAR(10), %1\$s, 102), '.', '-')"
                    . " + ' ' + CONVERT(CHAR(8), %1\$s, 20) ";
            break;
        default:
            $this->TimestampQueryFormat = false;
            die('unknown phptype/dbsyntax in setTimestampQueryFormat()');
    }
    return true;
}