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_driver.php17
-rw-r--r--system/database/drivers/interbase/interbase_driver.php4
-rw-r--r--system/database/drivers/mysql/mysql_driver.php29
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php20
-rw-r--r--system/database/drivers/oci8/oci8_driver.php2
-rw-r--r--system/database/drivers/odbc/odbc_driver.php17
-rw-r--r--system/database/drivers/pdo/pdo_driver.php13
-rw-r--r--system/database/drivers/postgre/postgre_driver.php18
-rw-r--r--system/database/drivers/sqlite/sqlite_driver.php17
-rw-r--r--system/database/drivers/sqlite3/sqlite3_driver.php17
10 files changed, 27 insertions, 127 deletions
diff --git a/system/database/drivers/cubrid/cubrid_driver.php b/system/database/drivers/cubrid/cubrid_driver.php
index 6b67b7546..7496ee42f 100644
--- a/system/database/drivers/cubrid/cubrid_driver.php
+++ b/system/database/drivers/cubrid/cubrid_driver.php
@@ -437,23 +437,6 @@ class CI_DB_cubrid_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.'LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
diff --git a/system/database/drivers/interbase/interbase_driver.php b/system/database/drivers/interbase/interbase_driver.php
index 5a03607ee..512ee62d2 100644
--- a/system/database/drivers/interbase/interbase_driver.php
+++ b/system/database/drivers/interbase/interbase_driver.php
@@ -421,12 +421,12 @@ class CI_DB_interbase_driver extends CI_DB {
if (stripos($this->version(), 'firebird') !== FALSE)
{
$select = 'FIRST '. (int) $limit
- .($offset > 0 ? ' SKIP '. (int) $offset : '');
+ .($offset ? ' SKIP '. (int) $offset : '');
}
else
{
$select = 'ROWS '
- .($offset > 0 ? (int) $offset.' TO '.($limit + $offset) : (int) $limit);
+ .($offset ? (int) $offset.' TO '.($limit + $offset) : (int) $limit);
}
return preg_replace('`SELECT`i', 'SELECT '.$select, $sql);
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index 8938d22b5..d11f015a6 100644
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -64,6 +64,12 @@ class CI_DB_mysql_driver extends CI_DB {
*/
public $delete_hack = TRUE;
+ /**
+ * Constructor
+ *
+ * @param array
+ * @return void
+ */
public function __construct($params)
{
parent::__construct($params);
@@ -74,6 +80,8 @@ class CI_DB_mysql_driver extends CI_DB {
}
}
+ // --------------------------------------------------------------------
+
/**
* Non-persistent database connection
*
@@ -335,7 +343,7 @@ class CI_DB_mysql_driver extends CI_DB {
*/
protected function _list_tables($prefix_limit = FALSE)
{
- $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char;
+ $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database);
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
{
@@ -355,7 +363,7 @@ class CI_DB_mysql_driver extends CI_DB {
* @param string the table name
* @return string
*/
- public function _list_columns($table = '')
+ protected function _list_columns($table = '')
{
return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
}
@@ -453,23 +461,6 @@ class CI_DB_mysql_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.' LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index d3fb77a22..d1581bf1a 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -335,7 +335,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
protected function _list_tables($prefix_limit = FALSE)
{
- $sql = 'SHOW TABLES FROM '.$this->_escape_char.$this->database.$this->_escape_char;
+ $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database);
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
{
@@ -455,24 +455,6 @@ class CI_DB_mysqli_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.' LIMIT '.$limit
- .($offset > 0 ? ' OFFSET '.$offset : '');
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index e78091614..1f571e586 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -634,7 +634,7 @@ class CI_DB_oci8_driver extends CI_DB {
{
$this->limit_used = TRUE;
return 'SELECT * FROM (SELECT inner_query.*, rownum rnum FROM ('.$sql.') inner_query WHERE rownum < '.($offset + $limit).')'
- .($offset !== 0 ? ' WHERE rnum >= '.$offset : '');
+ .($offset ? ' WHERE rnum >= '.$offset : '');
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 5ebba7aeb..bd5759289 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -331,23 +331,6 @@ class CI_DB_odbc_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.' LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php
index e25013a52..a3ad46900 100644
--- a/system/database/drivers/pdo/pdo_driver.php
+++ b/system/database/drivers/pdo/pdo_driver.php
@@ -599,19 +599,12 @@ class CI_DB_pdo_driver extends CI_DB {
*/
protected function _limit($sql, $limit, $offset)
{
- if ($this->pdodriver === 'cubrid' OR $this->pdodriver === 'sqlite')
+ if ($this->pdodriver === 'pgsql')
{
- $offset = ($offset == 0) ? '' : $offset.', ';
-
- return $sql.'LIMIT '.$offset.$limit;
+ return $sql.' LIMIT '.$limit.($offset ? ' OFFSET '.$offset : '');
}
- else
- {
- $sql .= 'LIMIT '.$limit;
- $sql .= ($offset > 0) ? ' OFFSET '.$offset : '';
- return $sql;
- }
+ return $sql.' LIMIT '.($offset ? $offset.', ' : '').$limit;
}
}
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 23826a0ae..fd253033b 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -399,11 +399,13 @@ class CI_DB_postgre_driver extends CI_DB {
*/
protected function _list_tables($prefix_limit = FALSE)
{
- $sql = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'";
+ $sql = 'SELECT "table_name" FROM "information_schema"."tables" WHERE "table_schema" = \'public\'';
if ($prefix_limit !== FALSE && $this->dbprefix !== '')
{
- return $sql." AND table_name LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
+ return $sql.' AND "table_name" LIKE \''
+ .$this->escape_like_str($this->dbprefix)."%' "
+ .sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
return $sql;
@@ -421,7 +423,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
protected function _list_columns($table = '')
{
- return "SELECT column_name FROM information_schema.columns WHERE table_name = '".$table."'";
+ return 'SELECT "column_name" FROM "information_schema"."columns" WHERE "table_name" = '.$this->escape($table);
}
// --------------------------------------------------------------------
@@ -580,7 +582,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
protected function _limit($sql, $limit, $offset)
{
- return $sql.' LIMIT '.$limit.($offset == 0 ? '' : ' OFFSET '.$offset);
+ return $sql.' LIMIT '.$limit.($offset ? ' OFFSET '.$offset : '');
}
// --------------------------------------------------------------------
@@ -593,13 +595,11 @@ class CI_DB_postgre_driver extends CI_DB {
* @param mixed
* @param mixed
* @param string
+ * @param mixed
* @return object
- *
*/
protected function _where($key, $value = NULL, $type = 'AND ', $escape = NULL)
{
- $type = $this->_group_get_type($type);
-
if ( ! is_array($key))
{
$key = array($key => $value);
@@ -610,7 +610,9 @@ class CI_DB_postgre_driver extends CI_DB {
foreach ($key as $k => $v)
{
- $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0) ? '' : $type;
+ $prefix = (count($this->qb_where) === 0 && count($this->qb_cache_where) === 0)
+ ? $this->_group_get_type('')
+ : $this->_group_get_type($type);
$k = (($op = $this->_get_operator($k)) !== FALSE)
? $this->protect_identifiers(substr($k, 0, strpos($k, $op)), FALSE, $escape).strstr($k, $op)
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 3305f6030..87be7a54a 100644
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -360,23 +360,6 @@ class CI_DB_sqlite_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.'LIMIT '.($offset == 0 ? '' : $offset.', ').$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void
diff --git a/system/database/drivers/sqlite3/sqlite3_driver.php b/system/database/drivers/sqlite3/sqlite3_driver.php
index bed61891b..1c6533f22 100644
--- a/system/database/drivers/sqlite3/sqlite3_driver.php
+++ b/system/database/drivers/sqlite3/sqlite3_driver.php
@@ -353,23 +353,6 @@ class CI_DB_sqlite3_driver extends CI_DB {
// --------------------------------------------------------------------
/**
- * Limit string
- *
- * Generates a platform-specific LIMIT clause
- *
- * @param string the sql query string
- * @param int the number of rows to limit the query to
- * @param int the offset value
- * @return string
- */
- protected function _limit($sql, $limit, $offset)
- {
- return $sql.' LIMIT '.($offset ? $offset.',' : '').$limit;
- }
-
- // --------------------------------------------------------------------
-
- /**
* Close DB Connection
*
* @return void