protected function functions(&$query)
    {

        switch ($this->mode) {

            case "mysql":
            case "odbc":
            case "sqlite":
                $query = preg_replace("/\bISNULL\(/", "IFNULL(", $query);
                break;

            case "postgres":
            case "redshift":
                $query = preg_replace("/\bI[FS]NULL\(/", "COALESCE(", $query);
                break;

            case "mssql":
            case "mssqlsrv":
                $query = preg_replace("/\bIFNULL\(/", "ISNULL(", $query);
                break;
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "odbc":
            case "mssql":
            case "mssqlsrv":
                $query = preg_replace("/\bSUBSTR\(/", "SUBSTRING(", $query);
                break;

            case "sqlite":
                $query = preg_replace("/\bSUBSTRING\(/", "SUBSTR(", $query);
                break;
        }

        switch ($this->mode) {

            case "postgres":
            case "redshift":
                $query = preg_replace("/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/", "TO_CHAR(ABSTIME($1), $3)", $query);
                break;
        }
    }
protected function functions(&$query)
    {

        switch ($this->mode) {

            case "mysql":
            case "odbc":
            case "sqlite":
                $query = preg_replace("/\bISNULL\(/", "IFNULL(", $query);
                break;

            case "postgres":
            case "redshift":
                $query = preg_replace("/\bI[FS]NULL\(/", "COALESCE(", $query);
                break;

            case "mssql":
            case "mssqlsrv":
                $query = preg_replace("/\bIFNULL\(/", "ISNULL(", $query);
                break;
        }

        switch ($this->mode) {

            case "mysql":
            case "postgres":
            case "redshift":
            case "odbc":
            case "mssql":
            case "mssqlsrv":
                $query = preg_replace("/\bSUBSTR\(/", "SUBSTRING(", $query);
                break;

            case "sqlite":
                $query = preg_replace("/\bSUBSTRING\(/", "SUBSTR(", $query);
                break;
        }

        switch ($this->mode) {

            case "postgres":
            case "redshift":
                $query = preg_replace("/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/", "TO_CHAR(ABSTIME($1), $3)", $query);
                break;
        }
    }
protected function functions ( & $ query ) { switch ( $ this -> mode ) { case "mysql" : case "odbc" : case "sqlite" : $ query = preg_replace ( "/\bISNULL\(/" , "IFNULL(" , $ query ) ; break ; case "postgres" : case "redshift" : $ query = preg_replace ( "/\bI[FS]NULL\(/" , "COALESCE(" , $ query ) ; break ; case "mssql" : case "mssqlsrv" : $ query = preg_replace ( "/\bIFNULL\(/" , "ISNULL(" , $ query ) ; break ; } switch ( $ this -> mode ) { case "mysql" : case "postgres" : case "redshift" : case "odbc" : case "mssql" : case "mssqlsrv" : $ query = preg_replace ( "/\bSUBSTR\(/" , "SUBSTRING(" , $ query ) ; break ; case "sqlite" : $ query = preg_replace ( "/\bSUBSTRING\(/" , "SUBSTR(" , $ query ) ; break ; } switch ( $ this -> mode ) { case "postgres" : case "redshift" : $ query = preg_replace ( "/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/" , "TO_CHAR(ABSTIME($1), $3)" , $ query ) ; break ; } }
Replace any non-standard functions with the appropriate function for the current mode
Replace any non - standard functions with the appropriate function for the current mode