This is documentation for Kohana v2.3.x.

Table of Contents
StatusDraft
TodoNeeds review

<< Back to Database Main Page

Database Metadata

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.

list_fields()

Database::list_fields($table) returns an array of the fields (columns) in the specified table.

field_data()

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:

table_exists()

Database::table_exists($table) returns TRUE or FALSE depending on whether the specified table exists in the database.

list_tables()

Database::list_tables() returns an array containing the names of all the tables in the database.

Continue to the next section: Database Query Caching >>