From d1403fd7268ccf96ab6e7d04506ea1b1802c7eb2 Mon Sep 17 00:00:00 2001 From: alecpl Date: Fri, 2 May 2008 07:35:00 +0000 Subject: - fixed #1485032 and updated MDB2 package+drivers --- program/lib/MDB2/Driver/Function/mssql.php | 369 +++++++++++++++-------------- 1 file changed, 192 insertions(+), 177 deletions(-) (limited to 'program/lib/MDB2/Driver/Function/mssql.php') diff --git a/program/lib/MDB2/Driver/Function/mssql.php b/program/lib/MDB2/Driver/Function/mssql.php index 4ee028169..1038901b6 100644 --- a/program/lib/MDB2/Driver/Function/mssql.php +++ b/program/lib/MDB2/Driver/Function/mssql.php @@ -1,178 +1,193 @@ - | -// +----------------------------------------------------------------------+ -// -// $Id: mssql.php,v 1.15 2007/08/11 16:02:22 quipo Exp $ -// - -require_once 'MDB2/Driver/Function/Common.php'; - -// {{{ class MDB2_Driver_Function_mssql -/** - * MDB2 MSSQL driver for the function modules - * - * @package MDB2 - * @category Database - * @author Lukas Smith - */ -class MDB2_Driver_Function_mssql extends MDB2_Driver_Function_Common -{ - // }}} - // {{{ executeStoredProc() - - /** - * Execute a stored procedure and return any results - * - * @param string $name string that identifies the function to execute - * @param mixed $params array that contains the paramaters to pass the stored proc - * @param mixed $types array that contains the types of the columns in - * the result set - * @param mixed $result_class string which specifies which result class to use - * @param mixed $result_wrap_class string which specifies which class to wrap results in - * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure - * @access public - */ - function &executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false) - { - $db =& $this->getDBInstance(); - if (PEAR::isError($db)) { - return $db; - } - - $query = 'EXECUTE '.$name; - $query .= $params ? ' '.implode(', ', $params) : ''; - return $db->query($query, $types, $result_class, $result_wrap_class); - } - - // }}} - // {{{ now() - - /** - * Return string to call a variable with the current timestamp inside an SQL statement - * There are three special variables for current date and time: - * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type) - * - CURRENT_DATE (date, DATE type) - * - CURRENT_TIME (time, TIME type) - * - * @return string to call a variable with the current timestamp - * @access public - */ - function now($type = 'timestamp') - { - switch ($type) { - case 'time': - case 'date': - case 'timestamp': - default: - return 'GETDATE()'; - } - } - - // }}} - // {{{ substring() - - /** - * return string to call a function to get a substring inside an SQL statement - * - * @return string to call a function to get a substring - * @access public - */ - function substring($value, $position = 1, $length = null) - { - if (!is_null($length)) { - return "SUBSTRING($value, $position, $length)"; - } - return "SUBSTRING($value, $position, LEN($value) - $position + 1)"; - } - - // }}} - // {{{ concat() - - /** - * Returns string to concatenate two or more string parameters - * - * @param string $value1 - * @param string $value2 - * @param string $values... - * @return string to concatenate two strings - * @access public - **/ - function concat($value1, $value2) - { - $args = func_get_args(); - return "(".implode(' + ', $args).")"; - } - - // }}} - // {{{ length() - - /** - * return string to call a function to get the length of a string expression - * - * @param string $expression - * @return return string to get the string expression length - * @access public - */ - function length($expression) - { - return "LEN($expression)"; - } - - // }}} - // {{{ guid() - - /** - * Returns global unique identifier - * - * @return string to get global unique identifier - * @access public - */ - function guid() - { - return 'NEWID()'; - } - - // }}} -} -// }}} + | +// +----------------------------------------------------------------------+ +// +// $Id: mssql.php,v 1.16 2008/02/17 18:54:08 quipo Exp $ +// + +require_once 'MDB2/Driver/Function/Common.php'; + +// {{{ class MDB2_Driver_Function_mssql +/** + * MDB2 MSSQL driver for the function modules + * + * @package MDB2 + * @category Database + * @author Lukas Smith + */ +class MDB2_Driver_Function_mssql extends MDB2_Driver_Function_Common +{ + // {{{ executeStoredProc() + + /** + * Execute a stored procedure and return any results + * + * @param string $name string that identifies the function to execute + * @param mixed $params array that contains the paramaters to pass the stored proc + * @param mixed $types array that contains the types of the columns in + * the result set + * @param mixed $result_class string which specifies which result class to use + * @param mixed $result_wrap_class string which specifies which class to wrap results in + * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure + * @access public + */ + function &executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false) + { + $db =& $this->getDBInstance(); + if (PEAR::isError($db)) { + return $db; + } + + $query = 'EXECUTE '.$name; + $query .= $params ? ' '.implode(', ', $params) : ''; + return $db->query($query, $types, $result_class, $result_wrap_class); + } + + // }}} + // {{{ now() + + /** + * Return string to call a variable with the current timestamp inside an SQL statement + * There are three special variables for current date and time: + * - CURRENT_TIMESTAMP (date and time, TIMESTAMP type) + * - CURRENT_DATE (date, DATE type) + * - CURRENT_TIME (time, TIME type) + * + * @return string to call a variable with the current timestamp + * @access public + */ + function now($type = 'timestamp') + { + switch ($type) { + case 'time': + case 'date': + case 'timestamp': + default: + return 'GETDATE()'; + } + } + + // }}} + // {{{ unixtimestamp() + + /** + * return string to call a function to get the unix timestamp from a iso timestamp + * + * @param string $expression + * + * @return string to call a variable with the timestamp + * @access public + */ + function unixtimestamp($expression) + { + return 'DATEDIFF(second, \'19700101\', '. $expression.') + DATEDIFF(second, GETDATE(), GETUTCDATE())'; + } + + // }}} + // {{{ substring() + + /** + * return string to call a function to get a substring inside an SQL statement + * + * @return string to call a function to get a substring + * @access public + */ + function substring($value, $position = 1, $length = null) + { + if (!is_null($length)) { + return "SUBSTRING($value, $position, $length)"; + } + return "SUBSTRING($value, $position, LEN($value) - $position + 1)"; + } + + // }}} + // {{{ concat() + + /** + * Returns string to concatenate two or more string parameters + * + * @param string $value1 + * @param string $value2 + * @param string $values... + * @return string to concatenate two strings + * @access public + **/ + function concat($value1, $value2) + { + $args = func_get_args(); + return "(".implode(' + ', $args).")"; + } + + // }}} + // {{{ length() + + /** + * return string to call a function to get the length of a string expression + * + * @param string $expression + * @return return string to get the string expression length + * @access public + */ + function length($expression) + { + return "LEN($expression)"; + } + + // }}} + // {{{ guid() + + /** + * Returns global unique identifier + * + * @return string to get global unique identifier + * @access public + */ + function guid() + { + return 'NEWID()'; + } + + // }}} +} +// }}} ?> \ No newline at end of file -- cgit v1.2.3