summaryrefslogtreecommitdiffstats
path: root/system/database/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/drivers')
-rw-r--r--system/database/drivers/cubrid/cubrid_forge.php3
-rw-r--r--system/database/drivers/mssql/mssql_driver.php1
-rw-r--r--system/database/drivers/mssql/mssql_forge.php5
-rw-r--r--system/database/drivers/mysql/mysql_driver.php1
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php1
-rw-r--r--system/database/drivers/oci8/oci8_driver.php20
-rw-r--r--system/database/drivers/oci8/oci8_forge.php1
-rw-r--r--system/database/drivers/odbc/odbc_driver.php161
-rw-r--r--system/database/drivers/pdo/pdo_driver.php5
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php3
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php7
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php5
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php1
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_oci_forge.php1
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php81
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php5
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_driver.php1
-rw-r--r--system/database/drivers/sqlsrv/sqlsrv_forge.php5
18 files changed, 172 insertions, 135 deletions
diff --git a/system/database/drivers/cubrid/cubrid_forge.php b/system/database/drivers/cubrid/cubrid_forge.php
index 8262beb6b..46a3b2185 100644
--- a/system/database/drivers/cubrid/cubrid_forge.php
+++ b/system/database/drivers/cubrid/cubrid_forge.php
@@ -178,6 +178,9 @@ class CI_DB_cubrid_forge extends CI_DB_forge {
$attributes['TYPE'] = 'INTEGER';
$attributes['UNSIGNED'] = FALSE;
return;
+ case 'LONGTEXT':
+ $attributes['TYPE'] = 'STRING';
+ return;
default: return;
}
}
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 72e31e00d..76f58564b 100644
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -159,6 +159,7 @@ class CI_DB_mssql_driver extends CI_DB {
if (mssql_select_db('['.$database.']', $this->conn_id))
{
$this->database = $database;
+ $this->data_cache = array();
return TRUE;
}
diff --git a/system/database/drivers/mssql/mssql_forge.php b/system/database/drivers/mssql/mssql_forge.php
index 24d1fc204..91b5794bc 100644
--- a/system/database/drivers/mssql/mssql_forge.php
+++ b/system/database/drivers/mssql/mssql_forge.php
@@ -113,6 +113,11 @@ class CI_DB_mssql_forge extends CI_DB_forge {
*/
protected function _attr_type(&$attributes)
{
+ if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
+ {
+ unset($attributes['CONSTRAINT']);
+ }
+
switch (strtoupper($attributes['TYPE']))
{
case 'MEDIUMINT':
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index d903406d1..70b4f68ba 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -220,6 +220,7 @@ class CI_DB_mysql_driver extends CI_DB {
if (mysql_select_db($database, $this->conn_id))
{
$this->database = $database;
+ $this->data_cache = array();
return TRUE;
}
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 431bce50a..168533240 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -263,6 +263,7 @@ class CI_DB_mysqli_driver extends CI_DB {
if ($this->conn_id->select_db($database))
{
$this->database = $database;
+ $this->data_cache = array();
return TRUE;
}
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 59f0e8456..df7e0848a 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -559,23 +559,29 @@ class CI_DB_oci8_driver extends CI_DB {
*/
public function error()
{
- /* oci_error() returns an array that already contains the
- * 'code' and 'message' keys, so we can just return it.
- */
+ // oci_error() returns an array that already contains
+ // 'code' and 'message' keys, but it can return false
+ // if there was no error ....
if (is_resource($this->curs_id))
{
- return oci_error($this->curs_id);
+ $error = oci_error($this->curs_id);
}
elseif (is_resource($this->stmt_id))
{
- return oci_error($this->stmt_id);
+ $error = oci_error($this->stmt_id);
}
elseif (is_resource($this->conn_id))
{
- return oci_error($this->conn_id);
+ $error = oci_error($this->conn_id);
+ }
+ else
+ {
+ $error = oci_error();
}
- return oci_error();
+ return is_array($error)
+ ? $error
+ : array('code' => '', 'message' => '');
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/oci8/oci8_forge.php b/system/database/drivers/oci8/oci8_forge.php
index 989c7a8b7..23e025757 100644
--- a/system/database/drivers/oci8/oci8_forge.php
+++ b/system/database/drivers/oci8/oci8_forge.php
@@ -182,5 +182,4 @@ class CI_DB_oci8_forge extends CI_DB_forge {
default: return;
}
}
-
}
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 19b7b744b..63df2963d 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -50,7 +50,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
* @author EllisLab Dev Team
* @link https://codeigniter.com/user_guide/database/
*/
-class CI_DB_odbc_driver extends CI_DB {
+class CI_DB_odbc_driver extends CI_DB_driver {
/**
* Database driver
@@ -94,6 +94,22 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * ODBC result ID resource returned from odbc_prepare()
+ *
+ * @var resource
+ */
+ private $odbc_result;
+
+ /**
+ * Values to use with odbc_execute() for prepared statements
+ *
+ * @var array
+ */
+ private $binds = array();
+
+ // --------------------------------------------------------------------
+
+ /**
* Class constructor
*
* @param array $params
@@ -128,6 +144,74 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
+ * Compile Bindings
+ *
+ * @param string $sql SQL statement
+ * @param array $binds An array of values to bind
+ * @return string
+ */
+ public function compile_binds($sql, $binds)
+ {
+ if (empty($binds) OR empty($this->bind_marker) OR strpos($sql, $this->bind_marker) === FALSE)
+ {
+ return $sql;
+ }
+ elseif ( ! is_array($binds))
+ {
+ $binds = array($binds);
+ $bind_count = 1;
+ }
+ else
+ {
+ // Make sure we're using numeric keys
+ $binds = array_values($binds);
+ $bind_count = count($binds);
+ }
+
+ // We'll need the marker length later
+ $ml = strlen($this->bind_marker);
+
+ // Make sure not to replace a chunk inside a string that happens to match the bind marker
+ if ($c = preg_match_all("/'[^']*'/i", $sql, $matches))
+ {
+ $c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i',
+ str_replace($matches[0],
+ str_replace($this->bind_marker, str_repeat(' ', $ml), $matches[0]),
+ $sql, $c),
+ $matches, PREG_OFFSET_CAPTURE);
+
+ // Bind values' count must match the count of markers in the query
+ if ($bind_count !== $c)
+ {
+ return $sql;
+ }
+ }
+ elseif (($c = preg_match_all('/'.preg_quote($this->bind_marker, '/').'/i', $sql, $matches, PREG_OFFSET_CAPTURE)) !== $bind_count)
+ {
+ return $sql;
+ }
+
+ if ($this->bind_marker !== '?')
+ {
+ do
+ {
+ $c--;
+ $sql = substr_replace($sql, '?', $matches[0][$c][1], $ml);
+ }
+ while ($c !== 0);
+ }
+
+ if (FALSE !== ($this->odbc_result = odbc_prepare($this->conn_id, $sql)))
+ {
+ $this->binds = array_values($binds);
+ }
+
+ return $sql;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Execute the query
*
* @param string $sql an SQL query
@@ -135,7 +219,25 @@ class CI_DB_odbc_driver extends CI_DB {
*/
protected function _execute($sql)
{
- return odbc_exec($this->conn_id, $sql);
+ if ( ! isset($this->odbc_result))
+ {
+ return odbc_exec($this->conn_id, $sql);
+ }
+ elseif ($this->odbc_result === FALSE)
+ {
+ return FALSE;
+ }
+
+ if (TRUE === ($success = odbc_execute($this->odbc_result, $this->binds)))
+ {
+ // For queries that return result sets, return the result_id resource on success
+ $this->is_write_type($sql) OR $success = $this->odbc_result;
+ }
+
+ $this->odbc_result = NULL;
+ $this->binds = array();
+
+ return $success;
}
// --------------------------------------------------------------------
@@ -214,7 +316,7 @@ class CI_DB_odbc_driver extends CI_DB {
*/
protected function _escape_str($str)
{
- return remove_invisible_characters($str);
+ $this->db->display_error('db_unsupported_feature');
}
// --------------------------------------------------------------------
@@ -312,58 +414,6 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Update statement
- *
- * Generates a platform-specific update string from the supplied data
- *
- * @param string $table
- * @param array $values
- * @return string
- */
- protected function _update($table, $values)
- {
- $this->qb_limit = FALSE;
- $this->qb_orderby = array();
- return parent::_update($table, $values);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Truncate statement
- *
- * Generates a platform-specific truncate string from the supplied data
- *
- * If the database does not support the TRUNCATE statement,
- * then this method maps to 'DELETE FROM table'
- *
- * @param string $table
- * @return string
- */
- protected function _truncate($table)
- {
- return 'DELETE FROM '.$table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @param string $table
- * @return string
- */
- protected function _delete($table)
- {
- $this->qb_limit = FALSE;
- return parent::_delete($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
@@ -372,5 +422,4 @@ class CI_DB_odbc_driver extends CI_DB {
{
odbc_close($this->conn_id);
}
-
}
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index c6f84e0f9..c27607e55 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -126,7 +126,10 @@ class CI_DB_pdo_driver extends CI_DB {
*/
public function db_connect($persistent = FALSE)
{
- $this->options[PDO::ATTR_PERSISTENT] = $persistent;
+ if ($persistent === TRUE)
+ {
+ $this->options[PDO::ATTR_PERSISTENT] = TRUE;
+ }
try
{
diff --git a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
index 5f854061d..b5b95078e 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_cubrid_forge.php
@@ -178,6 +178,9 @@ class CI_DB_pdo_cubrid_forge extends CI_DB_pdo_forge {
$attributes['TYPE'] = 'INTEGER';
$attributes['UNSIGNED'] = FALSE;
return;
+ case 'LONGTEXT':
+ $attributes['TYPE'] = 'STRING';
+ return;
default: return;
}
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
index 84695ee9b..9a1cbcaf4 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_driver.php
@@ -126,7 +126,12 @@ class CI_DB_pdo_dblib_driver extends CI_DB_pdo_driver {
*/
public function db_connect($persistent = FALSE)
{
- $this->conn_id = parent::db_connect($persistent);
+ if ($persistent === TRUE)
+ {
+ log_message('debug', "dblib driver doesn't support persistent connections");
+ }
+
+ $this->conn_id = parent::db_connect(FALSE);
if ( ! is_object($this->conn_id))
{
diff --git a/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php b/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php
index d5dd9aad1..830200325 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_dblib_forge.php
@@ -111,6 +111,11 @@ class CI_DB_pdo_dblib_forge extends CI_DB_pdo_forge {
*/
protected function _attr_type(&$attributes)
{
+ if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
+ {
+ unset($attributes['CONSTRAINT']);
+ }
+
switch (strtoupper($attributes['TYPE']))
{
case 'MEDIUMINT':
diff --git a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
index 70f2bfd4e..38a5a8aff 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_mysql_driver.php
@@ -218,6 +218,7 @@ class CI_DB_pdo_mysql_driver extends CI_DB_pdo_driver {
if (FALSE !== $this->simple_query('USE '.$this->escape_identifiers($database)))
{
$this->database = $database;
+ $this->data_cache = array();
return TRUE;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
index 94a52ffc8..705b1c711 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_oci_forge.php
@@ -173,5 +173,4 @@ class CI_DB_pdo_oci_forge extends CI_DB_pdo_forge {
default: return;
}
}
-
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
index 333448838..82554ec80 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_odbc_driver.php
@@ -161,6 +161,19 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
// --------------------------------------------------------------------
/**
+ * Platform-dependant string escape
+ *
+ * @param string
+ * @return string
+ */
+ protected function _escape_str($str)
+ {
+ $this->db->display_error('db_unsupported_feature');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Determines if a query is a "write" type.
*
* @param string An SQL query string
@@ -213,72 +226,4 @@ class CI_DB_pdo_odbc_driver extends CI_DB_pdo_driver {
{
return 'SELECT column_name FROM information_schema.columns WHERE table_name = '.$this->escape($table);
}
-
- // --------------------------------------------------------------------
-
- /**
- * Update statement
- *
- * Generates a platform-specific update string from the supplied data
- *
- * @param string $table
- * @param array $values
- * @return string
- */
- protected function _update($table, $values)
- {
- $this->qb_limit = FALSE;
- $this->qb_orderby = array();
- return parent::_update($table, $values);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Truncate statement
- *
- * Generates a platform-specific truncate string from the supplied data
- *
- * If the database does not support the TRUNCATE statement,
- * then this method maps to 'DELETE FROM table'
- *
- * @param string $table
- * @return string
- */
- protected function _truncate($table)
- {
- return 'DELETE FROM '.$table;
- }
-
- // --------------------------------------------------------------------
-
- /**
- * Delete statement
- *
- * Generates a platform-specific delete string from the supplied data
- *
- * @param string the table name
- * @return string
- */
- protected function _delete($table)
- {
- $this->qb_limit = FALSE;
- return parent::_delete($table);
- }
-
- // --------------------------------------------------------------------
-
- /**
- * LIMIT
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string $sql SQL Query
- * @return string
- */
- protected function _limit($sql)
- {
- return preg_replace('/(^\SELECT (DISTINCT)?)/i','\\1 TOP '.$this->qb_limit.' ', $sql);
- }
-
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php
index 602f895f1..56bf87f3a 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_sqlsrv_forge.php
@@ -111,6 +111,11 @@ class CI_DB_pdo_sqlsrv_forge extends CI_DB_pdo_forge {
*/
protected function _attr_type(&$attributes)
{
+ if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
+ {
+ unset($attributes['CONSTRAINT']);
+ }
+
switch (strtoupper($attributes['TYPE']))
{
case 'MEDIUMINT':
diff --git a/system/database/drivers/sqlsrv/sqlsrv_driver.php b/system/database/drivers/sqlsrv/sqlsrv_driver.php
index 0cd9ce16d..c55d5f7b7 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_driver.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_driver.php
@@ -171,6 +171,7 @@ class CI_DB_sqlsrv_driver extends CI_DB {
if ($this->_execute('USE '.$this->escape_identifiers($database)))
{
$this->database = $database;
+ $this->data_cache = array();
return TRUE;
}
diff --git a/system/database/drivers/sqlsrv/sqlsrv_forge.php b/system/database/drivers/sqlsrv/sqlsrv_forge.php
index f915dad3e..4f0ce9d6f 100644
--- a/system/database/drivers/sqlsrv/sqlsrv_forge.php
+++ b/system/database/drivers/sqlsrv/sqlsrv_forge.php
@@ -111,6 +111,11 @@ class CI_DB_sqlsrv_forge extends CI_DB_forge {
*/
protected function _attr_type(&$attributes)
{
+ if (isset($attributes['CONSTRAINT']) && strpos($attributes['TYPE'], 'INT') !== FALSE)
+ {
+ unset($attributes['CONSTRAINT']);
+ }
+
switch (strtoupper($attributes['TYPE']))
{
case 'MEDIUMINT':