This is documentation for Kohana v2.3.x.
Status | Draft |
---|---|
Todo | Needs review |
Below are methods that provide you with information about fields and tables in the database.
The usual way to call these methods would be from a method in your model, via $this→db
.
For example, you might do something like:
$this->db->list_fields('some_table');
Note: Calls to these methods will not show up in the information displayed by the profiler library.
Database::list_fields($table)
returns an array of the fields (columns) in the specified table.
Database::field_data($table)
returns an array, with one entry per field (collumn) in the database. Each entry in this array is an associative sub-array that specifies metadata about a field.
Note: The keys of the sub-array (and the metadata returned about each field) differ depending on the database driver in use.
Using the MySQL driver, each sub-array contains the following keys:
Database::table_exists($table)
returns TRUE or FALSE depending on whether the specified table exists in the database.
Database::list_tables()
returns an array containing the names of all the tables in the database.