public function columns_array($table)
{
//Array: field type null key default extra
$return = array();
if ($this->dbtype == 'mysql') {
$result = $this->query('SHOW COLUMNS FROM ' . $table);
while ($row = $result->fetch()) {
$return[$row['field']] = $row;
}
} elseif ($this->dbtype == 'oci') {
$result = $this->query("SELECT column_name, data_type, nullable, data_default, char_length FROM all_tab_columns WHERE table_name = '" . strtoupper($table) . "' ORDER BY column_id");
while ($row = $result->fetch()) {
if ($row['char_length']) {
$row['data_type'] .= '(' . $row['char_length'] . ')';
}
$column_name = strtolower($row['column_name']);
$_tmp = array();
$_tmp['field'] = $column_name;
$_tmp['type'] = $row['data_type'];
$_tmp['null'] = $row['nullable'] == 'N' ? 'NO' : 'YES';
$_tmp['key'] = '';
$_tmp['default'] = $row['data_default'];
$_tmp['extra'] = '';
$return[$column_name] = $_tmp;
}
}
return $return;
}