summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysqli
diff options
context:
space:
mode:
authordanmontgomery <noctrum@gmail.com>2011-08-21 21:31:22 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-10-27 14:21:51 +0200
commitad4681f7889beb66f44995882c3977239eb1b3df (patch)
treea521947d48cf3d7e40521255e1eddef0a96250d2 /system/database/drivers/mysqli
parent57514b96b89431d37b3eeea283a3ae0f36ac7ef4 (diff)
Fixed issue #150 (for mysql and mysqli), now returns the actual column length.
Diffstat (limited to 'system/database/drivers/mysqli')
-rw-r--r--system/database/drivers/mysqli/mysqli_driver.php2
-rw-r--r--system/database/drivers/mysqli/mysqli_result.php19
2 files changed, 13 insertions, 8 deletions
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index ddcaff323..ccd110f79 100644
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -442,7 +442,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function _field_data($table)
{
- return "SELECT * FROM ".$table." LIMIT 1";
+ return "DESCRIBE ".$table;
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php
index c4d8f5d58..ac863056a 100644
--- a/system/database/drivers/mysqli/mysqli_result.php
+++ b/system/database/drivers/mysqli/mysqli_result.php
@@ -84,21 +84,26 @@ class CI_DB_mysqli_result extends CI_DB_result {
function field_data()
{
$retval = array();
- while ($field = mysqli_fetch_field($this->result_id))
+ while ($field = mysqli_fetch_object($this->result_id))
{
+ preg_match('/([a-zA-Z]+)\((\d+)\)/', $field->Type, $matches);
+
+ $type = $matches[1];
+ $length = (int)$matches[2];
+
$F = new stdClass();
- $F->name = $field->name;
- $F->type = $field->type;
- $F->default = $field->def;
- $F->max_length = $field->max_length;
- $F->primary_key = ($field->flags & MYSQLI_PRI_KEY_FLAG) ? 1 : 0;
+ $F->name = $field->Field;
+ $F->type = $type;
+ $F->default = $field->Default;
+ $F->max_length = $length;
+ $F->primary_key = ( $field->Key == 'PRI' ? 1 : 0 );
$retval[] = $F;
}
return $retval;
}
-
+
// --------------------------------------------------------------------
/**