< DATE: Formatting   (Previous) Table of Contents (Next)   DATE: Formatting Query >

DATE: 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 setDateQueryFormat() {
    switch ($this->phptype . ':' . $this->dbsyntax) {
        case 'fbsql:fbsql':
        case 'ibase:firebird':
        case 'mysql:mysql':
        case 'mysqli:mysqli':
        case 'odbc:db2':
        case 'pgsql:pgsql':
        case 'sqlite:sqlite':
            $this->DateQueryFormat = ' %s ';
            break;
        case 'odbc:access':
            $this->DateQueryFormat = " FORMAT(%s, 'yyyy-mm-dd') ";
            break;
        case 'oci8:oci8':
            $this->DateQueryFormat = " TO_CHAR(%s, 'YYYY-MM-DD') ";
            break;
        case 'mssql:mssql':
            $this->DateQueryFormat = ' CONVERT(CHAR(10), %s, 120) ';
            break;
        case 'sybase:sybase':
            $this->DateQueryFormat = ' STR_REPLACE('
                    . " CONVERT(CHAR(10), %s, 102), '.', '-') ";
            break;
        default:
            $this->DateQueryFormat = false;
            die('unknown phptype/dbsyntax in setDateQueryFormat()');
    }
    return true;
}