summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli
diff options
context:
space:
mode:
authorJoël Cox <joel@joelcox.nl>2011-10-09 18:45:09 +0200
committerJoël Cox <joel@joelcox.nl>2011-10-09 18:45:09 +0200
commit8ffcb2c8c7ef3da54d7e46c29d502533e413c820 (patch)
tree1f94e2e81b4d20f2df827b8a84eeda27032161a1 /system/database/drivers/mysqli
parentf4fb1db458fab52d0493ead52c9ea7e01206eaa7 (diff)
parent6858c0753a7221796d6a5a1d7fea93cc2f9feb2e (diff)
Merged develop branch in tutorial.
Diffstat (limited to 'system/database/drivers/mysqli')
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php21
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php4
2 files changed, 7 insertions, 18 deletions
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index ccd110f79..abef80fbd 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -56,7 +56,7 @@ class CI_DB_mysqli_driver extends CI_DB {
// whether SET NAMES must be used to set the character set
var $use_set_names;
-
+
// --------------------------------------------------------------------
/**
@@ -135,20 +135,9 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function _db_set_charset($charset, $collation)
{
- if ( ! isset($this->use_set_names))
- {
- // mysqli_set_charset() requires MySQL >= 5.0.7, use SET NAMES as fallback
- $this->use_set_names = (version_compare(mysqli_get_server_info($this->conn_id), '5.0.7', '>=')) ? FALSE : TRUE;
- }
-
- if ($this->use_set_names === TRUE)
- {
- return @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
- }
- else
- {
- return @mysqli_set_charset($this->conn_id, $charset);
- }
+ return function_exists('mysqli_set_charset')
+ ? @mysqli_set_charset($this->conn_id, $charset)
+ : @mysqli_query($this->conn_id, "SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'");
}
// --------------------------------------------------------------------
@@ -570,7 +559,7 @@ class CI_DB_mysqli_driver extends CI_DB {
{
return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
}
-
+
// --------------------------------------------------------------------
/**
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;