summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
Diffstat (limited to 'system/database')
-rw-r--r--system/database/DB_active_rec.php2
-rw-r--r--system/database/DB_driver.php19
-rw-r--r--system/database/drivers/mysql/mysql_result.php4
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php4
-rw-r--r--system/database/drivers/oci8/oci8_driver.php1
-rw-r--r--system/database/drivers/odbc/odbc_driver.php2
6 files changed, 18 insertions, 14 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index 37d162bc1..89766e304 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -894,7 +894,7 @@ class CI_DB_active_record extends CI_DB_driver {
*/
public function offset($offset)
{
- $this->ar_offset = $offset;
+ $this->ar_offset = (int) $offset;
return $this;
}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index f9bf118fb..f3c6e41ad 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -251,9 +251,10 @@ class CI_DB_driver {
{
if ($sql == '')
{
+ log_message('error', 'Invalid query: '.$sql);
+
if ($this->db_debug)
{
- log_message('error', 'Invalid query: '.$sql);
return $this->display_error('db_invalid_query');
}
return FALSE;
@@ -306,21 +307,23 @@ class CI_DB_driver {
// This will trigger a rollback if transactions are being used
$this->_trans_status = FALSE;
+ // Grab the error number and message now, as we might run some
+ // additional queries before displaying the error
+ $error_no = $this->_error_number();
+ $error_msg = $this->_error_message();
+
+ // Log errors
+ log_message('error', 'Query error: '.$error_msg);
+
if ($this->db_debug)
{
- // grab the error number and message now, as we might run some
- // additional queries before displaying the error
- $error_no = $this->_error_number();
- $error_msg = $this->_error_message();
-
// We call this function in order to roll-back queries
// if transactions are enabled. If we don't call this here
// the error message will trigger an exit, causing the
// transactions to remain in limbo.
$this->trans_complete();
- // Log and display errors
- log_message('error', 'Query error: '.$error_msg);
+ // Display errors
return $this->display_error(
array(
'Error Number: '.$error_no,
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 2d2905c98..6ceaf4b9b 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -86,10 +86,10 @@ class CI_DB_mysql_result extends CI_DB_result {
$retval = array();
while ($field = mysql_fetch_object($this->result_id))
{
- preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches);
+ preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
$type = $matches[1];
- $length = (int)$matches[2];
+ $length = isset($matches[3]) ? (int) $matches[3] : NULL;
$F = new stdClass();
$F->name = $field->Field;
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index ac863056a..bbfb8481a 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -86,10 +86,10 @@ class CI_DB_mysqli_result extends CI_DB_result {
$retval = array();
while ($field = mysqli_fetch_object($this->result_id))
{
- preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches);
+ preg_match('/([a-zA-Z]+)(\((\d+)\))?/i', $field->Type, $matches);
$type = $matches[1];
- $length = (int)$matches[2];
+ $length = isset($matches[3]) ? (int) $matches[3] : NULL;
$F = new stdClass();
$F->name = $field->Field;
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 42cfaaefb..d4adfd528 100644
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -404,6 +404,7 @@ class CI_DB_oci8_driver extends CI_DB {
}
$str = remove_invisible_characters($str);
+ $str = str_replace("'", "''", $str);
// escape LIKE condition wildcards
if ($like === TRUE)
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index 5e764e071..08cd27b6c 100644
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -50,7 +50,7 @@ class CI_DB_odbc_driver extends CI_DB {
function CI_DB_odbc_driver($params)
{
- parent::CI_DB($params);
+ parent::CI_DB_driver($params);
$this->_random_keyword = ' RND('.time().')'; // database specific random keyword
}