Enabled list_columns to handle like queries
This commit is contained in:
parent
bc2d62980c
commit
ae491aae7f
@ -166,29 +166,22 @@ class Kohana_Database_DB2 extends Database {
|
||||
// Make sure the database is connected
|
||||
$this->_connection or $this->connect();
|
||||
|
||||
$table = strtoupper($table);
|
||||
|
||||
// Quote the table name
|
||||
$table = ($add_prefix === TRUE) ? $this->quote_table($table) : $table;
|
||||
|
||||
if (is_string($like))
|
||||
{
|
||||
// Search for column names
|
||||
throw new Kohana_Exception('Like queries not implemented');
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find all column names
|
||||
try {
|
||||
$result = db2_columns($this->_connection,NULL,$this->_config['connection']['schema'] ? $this->_config['connection']['schema'] : '%',$table);
|
||||
$result = db2_columns($this->_connection,NULL,$this->_config['connection']['schema'] ? $this->_config['connection']['schema'] : '%',$table,$like);
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new Database_Exception('Unable to obtain Columns for :table [:error]',array(':table'=>$table,':error' => db2_stmt_errormsg()),db2_stmt_error());
|
||||
}
|
||||
throw new Database_Exception('Unable to obtain Columns for :table [:error] (:like)',array(':like'=>$like,':table'=>$table,':error' => db2_stmt_errormsg()),db2_stmt_error());
|
||||
}
|
||||
|
||||
$count = 0;
|
||||
$columns = array();
|
||||
while ($row = db2_fetch_assoc($result))
|
||||
{
|
||||
while ($row = db2_fetch_assoc($result)) {
|
||||
list($type, $length) = $this->_parse_type($row['TYPE_NAME']);
|
||||
|
||||
$column = $this->datatype($type);
|
||||
@ -240,6 +233,10 @@ class Kohana_Database_DB2 extends Database {
|
||||
$columns[$row['COLUMN_NAME']] = $column;
|
||||
}
|
||||
|
||||
if (! $columns)
|
||||
throw new Database_Exception('Unable to obtain Columns for :table [:error] (:like)',
|
||||
array(':like'=>$like,':table'=>$table,':error' => db2_conn_errormsg()),db2_conn_error());
|
||||
|
||||
// Save our cache data for next call
|
||||
if ($this->_config['caching']) {
|
||||
Kohana::cache($cache_key,$columns);
|
||||
|
Reference in New Issue
Block a user