diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-11-16 00:49:46 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-11-16 00:49:46 +0100 |
commit | 02e7a9d6509092315dd31183762616860ebb9621 (patch) | |
tree | 0010226704e6f2def7df8667bdf9c9e802f5581a /system/database/drivers/ibase | |
parent | f1e1b7789b9adaf0b38b8386c99f46fc37507c8f (diff) |
Improve DB field_data() for Interbase / Firebird
Diffstat (limited to 'system/database/drivers/ibase')
-rw-r--r-- | system/database/drivers/ibase/ibase_driver.php | 45 | ||||
-rw-r--r-- | system/database/drivers/ibase/ibase_result.php | 2 |
2 files changed, 36 insertions, 11 deletions
diff --git a/system/database/drivers/ibase/ibase_driver.php b/system/database/drivers/ibase/ibase_driver.php index 02ec354e3..15c2a4630 100644 --- a/system/database/drivers/ibase/ibase_driver.php +++ b/system/database/drivers/ibase/ibase_driver.php @@ -289,19 +289,46 @@ class CI_DB_ibase_driver extends CI_DB { // -------------------------------------------------------------------- /** - * Field data query - * - * Generates a platform-specific query so that the column data can be retrieved + * Returns an object with field data * * @param string $table - * @return string + * @return array */ - protected function _field_data($table) + public function field_data($table = '') { - $this->qb_limit = 1; - $sql = $this->_limit('SELECT * FROM '.$this->protect_identifiers($table)); - $this->qb_limit = 0; - return $sql; + if ($table === '') + { + return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE; + } + + $sql = 'SELECT "rfields"."RDB$FIELD_NAME" AS "name", + CASE "fields"."RDB$FIELD_TYPE" + WHEN 7 THEN \'SMALLINT\' + WHEN 8 THEN \'INTEGER\' + WHEN 9 THEN \'QUAD\' + WHEN 10 THEN \'FLOAT\' + WHEN 11 THEN \'DFLOAT\' + WHEN 12 THEN \'DATE\' + WHEN 13 THEN \'TIME\' + WHEN 14 THEN \'CHAR\' + WHEN 16 THEN \'INT64\' + WHEN 27 THEN \'DOUBLE\' + WHEN 35 THEN \'TIMESTAMP\' + WHEN 37 THEN \'VARCHAR\' + WHEN 40 THEN \'CSTRING\' + WHEN 261 THEN \'BLOB\' + ELSE NULL + END AS "type", + "fields"."RDB$FIELD_LENGTH" AS "max_length", + "rfields"."RDB$DEFAULT_VALUE" AS "default" + FROM "RDB$RELATION_FIELDS" "rfields" + JOIN "RDB$FIELDS" "fields" ON "rfields"."RDB$FIELD_SOURCE" = "fields"."RDB$FIELD_NAME" + WHERE "rfields"."RDB$RELATION_NAME" = '.$this->escape($table).' + ORDER BY "rfields"."RDB$FIELD_POSITION"'; + + return (($query = $this->query($sql)) !== FALSE) + ? $query->result_object() + : FALSE; } // -------------------------------------------------------------------- diff --git a/system/database/drivers/ibase/ibase_result.php b/system/database/drivers/ibase/ibase_result.php index bbad9d895..4f5637a72 100644 --- a/system/database/drivers/ibase/ibase_result.php +++ b/system/database/drivers/ibase/ibase_result.php @@ -89,8 +89,6 @@ class CI_DB_ibase_result extends CI_DB_result { $retval[$i]->name = $info['name']; $retval[$i]->type = $info['type']; $retval[$i]->max_length = $info['length']; - $retval[$i]->primary_key = 0; - $retval[$i]->default = ''; } return $retval; |