summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mssql/mssql_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers/mssql/mssql_driver.php')
-rwxr-xr-x[-rw-r--r--]system/database/drivers/mssql/mssql_driver.php131
1 files changed, 64 insertions, 67 deletions
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index f301ba533..5a69132cd 100644..100755
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -31,14 +31,14 @@
class CI_DB_mssql_driver extends CI_DB {
var $dbdriver = 'mssql';
-
+
// The character used for escaping
var $_escape_char = '';
// clause and character used for LIKE escape sequences
var $_like_escape_str = " ESCAPE '%s' ";
var $_like_escape_chr = '!';
-
+
/**
* The syntax to count rows is slightly different across different
* database engines, so this string appears in each driver and is
@@ -52,7 +52,7 @@ class CI_DB_mssql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_connect()
{
if ($this->port != '')
@@ -62,7 +62,7 @@ class CI_DB_mssql_driver extends CI_DB {
return @mssql_connect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
/**
@@ -70,7 +70,7 @@ class CI_DB_mssql_driver extends CI_DB {
*
* @access private called by the base class
* @return resource
- */
+ */
function db_pconnect()
{
if ($this->port != '')
@@ -80,9 +80,9 @@ class CI_DB_mssql_driver extends CI_DB {
return @mssql_pconnect($this->hostname, $this->username, $this->password);
}
-
+
// --------------------------------------------------------------------
-
+
/**
* Reconnect
*
@@ -98,13 +98,13 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Select the database
*
* @access private called by the base class
* @return resource
- */
+ */
function db_select()
{
// Note: The brackets are required in the event that the DB name
@@ -113,7 +113,7 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Set client character set
*
@@ -129,20 +129,20 @@ class CI_DB_mssql_driver extends CI_DB {
}
// --------------------------------------------------------------------
-
+
/**
* Execute the query
*
* @access private called by the base class
* @param string an SQL query
* @return resource
- */
+ */
function _execute($sql)
{
$sql = $this->_prep_query($sql);
return @mssql_query($sql, $this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -153,7 +153,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @access private called by execute()
* @param string an SQL query
* @return string
- */
+ */
function _prep_query($sql)
{
return $sql;
@@ -165,15 +165,15 @@ class CI_DB_mssql_driver extends CI_DB {
* Begin Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_begin($test_mode = FALSE)
{
if ( ! $this->trans_enabled)
{
return TRUE;
}
-
+
// When transactions are nested we only begin/commit/rollback the outermost ones
if ($this->_trans_depth > 0)
{
@@ -195,8 +195,8 @@ class CI_DB_mssql_driver extends CI_DB {
* Commit Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_commit()
{
if ( ! $this->trans_enabled)
@@ -220,8 +220,8 @@ class CI_DB_mssql_driver extends CI_DB {
* Rollback Transaction
*
* @access public
- * @return bool
- */
+ * @return bool
+ */
function trans_rollback()
{
if ( ! $this->trans_enabled)
@@ -238,7 +238,7 @@ class CI_DB_mssql_driver extends CI_DB {
$this->simple_query('ROLLBACK TRAN');
return TRUE;
}
-
+
// --------------------------------------------------------------------
/**
@@ -254,19 +254,16 @@ class CI_DB_mssql_driver extends CI_DB {
if (is_array($str))
{
foreach($str as $key => $val)
- {
+ {
$str[$key] = $this->escape_str($val, $like);
- }
-
- return $str;
- }
-
- // Access the CI object
- $CI =& get_instance();
-
+ }
+
+ return $str;
+ }
+
// Escape single quotes
- $str = str_replace("'", "''", $CI->input->_remove_invisible_characters($str));
-
+ $str = str_replace("'", "''", remove_invisible_characters($str));
+
// escape LIKE condition wildcards
if ($like === TRUE)
{
@@ -274,10 +271,10 @@ class CI_DB_mssql_driver extends CI_DB {
array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
$str);
}
-
+
return $str;
}
-
+
// --------------------------------------------------------------------
/**
@@ -290,7 +287,7 @@ class CI_DB_mssql_driver extends CI_DB {
{
return @mssql_rows_affected($this->conn_id);
}
-
+
// --------------------------------------------------------------------
/**
@@ -315,7 +312,7 @@ class CI_DB_mssql_driver extends CI_DB {
/**
* Parse major version
*
- * Grabs the major version number from the
+ * Grabs the major version number from the
* database server version string passed in.
*
* @access private
@@ -385,14 +382,14 @@ class CI_DB_mssql_driver extends CI_DB {
function _list_tables($prefix_limit = FALSE)
{
$sql = "SELECT name FROM sysobjects WHERE type = 'U' ORDER BY name";
-
+
// for future compatibility
if ($prefix_limit !== FALSE AND $this->dbprefix != '')
{
- //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_char);
+ //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
return FALSE; // not currently supported
}
-
+
return $sql;
}
@@ -409,7 +406,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function _list_columns($table = '')
{
- return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
+ return "SELECT * FROM INFORMATION_SCHEMA.Columns WHERE TABLE_NAME = '".$table."'";
}
// --------------------------------------------------------------------
@@ -425,7 +422,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function _field_data($table)
{
- return "SELECT TOP 1 * FROM ".$table;
+ return "SELECT TOP 1 * FROM ".$table;
}
// --------------------------------------------------------------------
@@ -440,7 +437,7 @@ class CI_DB_mssql_driver extends CI_DB {
{
return mssql_get_last_message();
}
-
+
// --------------------------------------------------------------------
/**
@@ -477,26 +474,26 @@ class CI_DB_mssql_driver extends CI_DB {
{
if (strpos($item, '.'.$id) !== FALSE)
{
- $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
-
+ $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
- }
+ }
}
if (strpos($item, '.') !== FALSE)
{
- $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
+ $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
}
else
{
$str = $this->_escape_char.$item.$this->_escape_char;
}
-
+
// remove duplicates if the user already included the escape
return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
}
-
+
// --------------------------------------------------------------------
/**
@@ -515,12 +512,12 @@ class CI_DB_mssql_driver extends CI_DB {
{
$tables = array($tables);
}
-
+
return implode(', ', $tables);
}
// --------------------------------------------------------------------
-
+
/**
* Insert statement
*
@@ -533,10 +530,10 @@ class CI_DB_mssql_driver extends CI_DB {
* @return string
*/
function _insert($table, $keys, $values)
- {
+ {
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
}
-
+
// --------------------------------------------------------------------
/**
@@ -558,21 +555,21 @@ class CI_DB_mssql_driver extends CI_DB {
{
$valstr[] = $key." = ".$val;
}
-
+
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
$orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
+
$sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
$sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
$sql .= $orderby.$limit;
-
+
return $sql;
}
-
+
// --------------------------------------------------------------------
/**
@@ -585,12 +582,12 @@ class CI_DB_mssql_driver extends CI_DB {
* @access public
* @param string the table name
* @return string
- */
+ */
function _truncate($table)
{
return "TRUNCATE ".$table;
}
-
+
// --------------------------------------------------------------------
/**
@@ -603,7 +600,7 @@ class CI_DB_mssql_driver extends CI_DB {
* @param array the where clause
* @param string the limit clause
* @return string
- */
+ */
function _delete($table, $where = array(), $like = array(), $limit = FALSE)
{
$conditions = '';
@@ -621,7 +618,7 @@ class CI_DB_mssql_driver extends CI_DB {
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
+
return "DELETE FROM ".$table.$conditions.$limit;
}
@@ -641,8 +638,8 @@ class CI_DB_mssql_driver extends CI_DB {
function _limit($sql, $limit, $offset)
{
$i = $limit + $offset;
-
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
+
+ return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$i.' ', $sql);
}
// --------------------------------------------------------------------
@@ -657,7 +654,7 @@ class CI_DB_mssql_driver extends CI_DB {
function _close($conn_id)
{
@mssql_close($conn_id);
- }
+ }
}