* psql [dbname] < /usr/share/pgsql/contrib/pgcrypto.sql * * You should make sure you run this as the postgres user. * * @return string */ public function md5( $column ) { $version = $this->db->getAttribute( PDO::ATTR_SERVER_VERSION ); if( substr( $version, 0, 1 ) == 8 ) // from version 8 { return "MD5( {$column} )"; } else { return " encode( digest( $column, 'md5' ), 'hex' ) "; } } /** * Returns part of a string. * * Note: Not SQL92, but common functionality. * * @param string $value the target $value the string or the string column. * @param integer $from extract from this characeter. * @param integer $len extract this amount of characters. * @return string sql that extracts part of a string. */ public function subString( $value, $from, $len = null ) { if ( $len === null ) { return "substr( {$value}, {$from} )"; } else { return "substr( {$value}, {$from}, {$len} )"; } } /** * Returns a series of strings concatinated * * concat() accepts an arbitrary number of parameters. Each parameter * must contain an expression or an array with expressions. * * @param string|array(string) strings that will be concatinated. */ public function concat() { $args = func_get_args(); $cols = self::arrayFlatten( $args ); if ( count( $cols ) < 1 ) { throw new ezcDbAbstractionException( ezcDbAbstractoinException::INVALID_ARGUMENT_NUM ); } return join( ' || ' , $cols ); } } ?>