diff options
author | Andrey Andreev <narf@devilix.net> | 2015-04-29 11:33:11 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2015-04-29 11:33:11 +0200 |
commit | 0f8509025d2338dc069ddf42b6ade974a5da0ca3 (patch) | |
tree | d560f5d241eef7ed11f6a68bdd6833046cf725ec /system/database/drivers/pdo/subdrivers | |
parent | b137d232ef895cc47da4e39dfcb7c9078ba6be2b (diff) |
Add list_fields() support for SQLite3
Diffstat (limited to 'system/database/drivers/pdo/subdrivers')
-rw-r--r-- | system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php index f07f49f84..d5ca741fd 100644 --- a/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php +++ b/system/database/drivers/pdo/subdrivers/pdo_sqlite_driver.php @@ -121,17 +121,31 @@ class CI_DB_pdo_sqlite_driver extends CI_DB_pdo_driver { // -------------------------------------------------------------------- /** - * Show column query + * Fetch Field Names * - * Generates a platform-specific query string so that the column names can be fetched - * - * @param string $table - * @return string + * @param string $table Table name + * @return array */ - protected function _list_columns($table = '') + public function list_fields($table) { - // Not supported - return FALSE; + // Is there a cached result? + if (isset($this->data_cache['field_names'][$table])) + { + return $this->data_cache['field_names'][$table]; + } + + if (($result = $this->query('PRAGMA TABLE_INFO('.$this->protect_identifiers($table, TRUE, NULL, FALSE).')')) === FALSE) + { + return FALSE; + } + + $this->data_cache['field_names'][$table] = array(); + foreach ($result as $row) + { + $this->data_cache['field_names'][$table][] = $row['name']; + } + + return $this->data_cache['field_names'][$table]; } // -------------------------------------------------------------------- |