summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/mysql/mysql_result.php
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-08-21 23:22:23 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-08-21 23:22:23 +0200
commit297eb2fa755d8d0202511d4181dc4dab115e842c (patch)
treefbb39a5e46f35e43af0af0aab6f12cdc7e92bd6a /system/database/drivers/mysql/mysql_result.php
parent70fb1fdb96df64f2282d00330c98f79aa0adec50 (diff)
parentfc7564545fb166553a7080b8dbd2b9941925734d (diff)
Merge pull request #247 from danmontgomery/develop
Fixes issue #150, field_data() 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;
}