Db::getColumnDetails
Usage
array Db::getColumnDetails(string $table_name)Description
Get details on all columns within a database table including type, whether it's primary or unique, allows null, et al.Parameters
Parameter | Required | Type | Description |
---|---|---|---|
$table_name | Yes | string | The table name to retrieve details of. |
Return Value
Returns an associative array with the keys being the column names, and the values being an associative array of details regarding the column.Examples
Get Column Details
$table = 'admin';
$details = $this->db->getColumnDetails($table);
// Display details
print_r($details);
// This will display something such as:
Array
(
[uuid] => Array
(
[type] => varchar(30)
[length] => 30
[is_primary] => 1
[is_unique] =>
[is_auto_increment] =>
[key] => pri
[allow_null] =>
[default] =>
)
[language] => Array
(
[type] => varchar(5)
[length] => 5
[is_primary] =>
[is_unique] =>
[is_auto_increment] =>
[key] =>
[allow_null] =>
[default] => en
)
[timezone] => Array
(
[type] => varchar(5)
[length] => 5
[is_primary] =>
[is_unique] =>
[is_auto_increment] =>
[key] =>
[allow_null] =>
[default] => EST
)
[full_name] => Array
(
[type] => varchar(100)
[length] => 100
[is_primary] =>
[is_unique] =>
[is_auto_increment] =>
[key] =>
[allow_null] =>
[default] =>
)