From cb2bc809ef29f349d38c89e202d821e67bb4c947 Mon Sep 17 00:00:00 2001 From: thomascube <thomas@roundcube.net> Date: Tue, 21 Sep 2010 14:47:55 -0400 Subject: [PATCH] Fix db_mode check in insert_id() --- program/lib/MDB2/Driver/sqlsrv.php | 40 ++++++++++++++++++---------------------- 1 files changed, 18 insertions(+), 22 deletions(-) diff --git a/program/lib/MDB2/Driver/sqlsrv.php b/program/lib/MDB2/Driver/sqlsrv.php index 7f1017a..70f9780 100644 --- a/program/lib/MDB2/Driver/sqlsrv.php +++ b/program/lib/MDB2/Driver/sqlsrv.php @@ -113,9 +113,6 @@ function errorInfo($error = null, $connection = null) { if (null === $connection) { - if (!$this->connection) { - $this->connect(); - } $connection = $this->connection; } @@ -479,7 +476,7 @@ $query = $this->_modifyQuery($query, $is_manip, $this->limit, $this->offset); $this->offset = $this->limit = 0; - $result =& $this->_doQuery($query, $is_manip, $connection); + $result = $this->_doQuery($query, $is_manip, $connection); if (!PEAR::isError($result)) { $result = $this->_affectedRows($connection, $result); } @@ -500,7 +497,7 @@ * @return result or error object * @access protected */ - function &_doQuery($query, $is_manip = false, $connection = null, $database_name = null) + function _doQuery($query, $is_manip = false, $connection = null, $database_name = null) { $this->last_query = $query; $result = $this->debug($query, 'query', array('is_manip' => $is_manip, 'when' => 'pre')); @@ -539,7 +536,7 @@ $query = preg_replace('/DATE_FORMAT\(([\w|.]*)\, \'\%Y\-\%m\-\%d %H\:00\:00\'\)/i','CONVERT(varchar(13),$1,120)+\':00:00\'',$query); $result = @sqlsrv_query($connection,$query); if (!$result) { - $err =& $this->raiseError(null, null, null, + $err = $this->raiseError(null, null, null, 'Could not execute statement', __FUNCTION__); return $err; } @@ -689,7 +686,7 @@ } else { $query = "INSERT INTO $sequence_name ($seqcol_name) VALUES (0)"; } - $result =& $this->_doQuery($query, true); + $result = $this->_doQuery($query, true); $this->popExpect(); $this->popErrorHandling(); if (PEAR::isError($result)) { @@ -723,7 +720,7 @@ $value = $this->lastInsertID($sequence_name); if (is_numeric($value)) { $query = "DELETE FROM $sequence_name WHERE $seqcol_name < $value"; - $result =& $this->_doQuery($query, true); + $result = $this->_doQuery($query, true); if (PEAR::isError($result)) { $this->warnings[] = 'nextID: could not delete previous sequence table values from '.$seq_name; } @@ -764,15 +761,15 @@ */ class MDB2_Result_sqlsrv extends MDB2_Result_Common { - // {{{ constructor: function __construct(&$db, &$result, $limit = 0, $offset = 0) + // {{{ constructor: function __construct($db, $result, $limit = 0, $offset = 0) /** * Constructor */ - function __construct(&$db, &$result, $limit = 0, $offset = 0) + function __construct($db, $result, $limit = 0, $offset = 0) { - $this->db =& $db; - $this->result =& $result; + $this->db = $db; + $this->result = $result; $this->offset = $offset; $this->limit = max(0, $limit - 1); $this->cursor = 0; @@ -787,11 +784,12 @@ continue; } foreach ($row as $k => $v) { - if (is_object($v) && method_exists($v, 'format')) {//DateTime Object - $row[$k] = $v->format("Y-m-d H:i:s"); + if (is_object($v) && method_exists($v, 'format')) { + //DateTime Object + $row[$k] = $v->format('Y-m-d H:i:s'); } } - $this->rows[] = $row;//read results into memory, cursors are not supported + $this->rows[] = $row; //read results into memory, cursors are not supported } } $this->rowcnt = count($this->rows); @@ -848,14 +846,13 @@ * @return int data array on success, a MDB2 error on failure * @access public */ - function &fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) + function fetchRow($fetchmode = MDB2_FETCHMODE_DEFAULT, $rownum = null) { if (!$this->result) { return $this->db->raiseError(MDB2_ERROR_INVALID, null, null, 'no valid statement given', __FUNCTION__); } if (($this->limit && $this->rownum >= $this->limit) || ($this->cursor >= $this->rowcnt || $this->rowcnt == 0)) { - $null = null; - return $null; + return null; } if (null !== $rownum) { $seek = $this->seek($rownum); @@ -911,12 +908,11 @@ } if (!$row) { if (false === $this->result) { - $err =& $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, + $err = $this->db->raiseError(MDB2_ERROR_NEED_MORE_DATA, null, null, 'resultset has already been freed', __FUNCTION__); return $err; } - $null = null; - return $null; + return null; } $mode = $this->db->options['portability'] & MDB2_PORTABILITY_EMPTY_TO_NULL; $rtrim = false; @@ -1162,4 +1158,4 @@ // }}} -?> \ No newline at end of file +?> -- Gitblit v1.9.1