summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysql/mysql_result.php
diff options
context:
space:
mode:
authordanmontgomery <noctrum@gmail.com>2011-08-21 21:31:22 +0200
committerdanmontgomery <noctrum@gmail.com>2011-08-21 21:31:22 +0200
commitfc7564545fb166553a7080b8dbd2b9941925734d (patch)
tree6fead350a86ed0711a31ab3f38a1934a67e6c8d5 /system/database/drivers/mysql/mysql_result.php
parent9c631750dfa62c748ef9cd9bccdde3250d6e5b72 (diff)
Fixed issue #150 (for mysql and mysqli), now returns the actual column length.
Diffstat (limited to 'system/database/drivers/mysql/mysql_result.php')
-rw-r--r--system/database/drivers/mysql/mysql_result.php17
1 files changed, 11 insertions, 6 deletions
diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php
index 507389603..2d2905c98 100644
--- a/system/database/drivers/mysql/mysql_result.php
+++ b/system/database/drivers/mysql/mysql_result.php
@@ -84,14 +84,19 @@ class CI_DB_mysql_result extends CI_DB_result {
function field_data()
{
$retval = array();
- while ($field = mysql_fetch_field($this->result_id))
+ while ($field = mysql_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->primary_key;
+ $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;
}