summaryrefslogtreecommitdiffstats
path: root/system/database/drivers/pdo/pdo_result.php
diff options
context:
space:
mode:
authorTaufan Aditya <toopay@taufanaditya.com>2012-02-18 16:47:36 +0100
committerTaufan Aditya <toopay@taufanaditya.com>2012-02-18 16:47:36 +0100
commit4e44b344d79b52c7b79489b7e3d137d5ed66ab21 (patch)
treea99d42300d8ca6c2762bd7e5600b8f40d9ef4982 /system/database/drivers/pdo/pdo_result.php
parent7a2412cfe7f7d8db3eb845542609c476c52efc3d (diff)
Fixed meta table method(s) for PDO
Diffstat (limited to 'system/database/drivers/pdo/pdo_result.php')
-rw-r--r--system/database/drivers/pdo/pdo_result.php43
1 files changed, 41 insertions, 2 deletions
diff --git a/system/database/drivers/pdo/pdo_result.php b/system/database/drivers/pdo/pdo_result.php
index c333abc40..213b5d670 100644
--- a/system/database/drivers/pdo/pdo_result.php
+++ b/system/database/drivers/pdo/pdo_result.php
@@ -160,9 +160,48 @@ class CI_DB_pdo_result extends CI_DB_result {
try
{
- for($i = 0; $i < $this->num_fields(); $i++)
+ if (strpos($this->result_id->queryString, 'PRAGMA') !== FALSE)
{
- $data[] = $this->result_id->getColumnMeta($i);
+ foreach($this->result_array() as $field)
+ {
+ preg_match('/([a-zA-Z]+)(\(\d+\))?/', $field['type'], $matches);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = ( ! empty($matches[1])) ? $matches[1] : NULL;
+ $F->default = NULL;
+ $F->max_length = ( ! empty($matches[2])) ? preg_replace('/[^\d]/', '', $matches[2]) : NULL;
+ $F->primary_key = (int) $field['pk'];
+ $F->pdo_type = NULL;
+
+ $data[] = $F;
+ }
+ }
+ else
+ {
+ for($i = 0, $max = $this->num_fields(); $i < $max; $i++)
+ {
+ $field = $this->result_id->getColumnMeta($i);
+
+ $F = new stdClass();
+ $F->name = $field['name'];
+ $F->type = $field['native_type'];
+ $F->default = NULL;
+ $F->pdo_type = $field['pdo_type'];
+
+ if ($field['precision'] < 0)
+ {
+ $F->max_length = NULL;
+ $F->primary_key = 0;
+ }
+ else
+ {
+ $F->max_length = ($field['len'] > 255) ? NULL : (string) $field['len'];
+ $F->primary_key = (int) (array_key_exists('flags', $field) && in_array('primary_key', $field['flags']));
+ }
+
+ $data[] = $F;
+ }
}
return $data;