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
|
// Make sure the database is connected
|
||||||
$this->_connection or $this->connect();
|
$this->_connection or $this->connect();
|
||||||
|
|
||||||
|
$table = strtoupper($table);
|
||||||
|
|
||||||
// Quote the table name
|
// Quote the table name
|
||||||
$table = ($add_prefix === TRUE) ? $this->quote_table($table) : $table;
|
$table = ($add_prefix === TRUE) ? $this->quote_table($table) : $table;
|
||||||
|
|
||||||
if (is_string($like))
|
// Find all column names
|
||||||
{
|
try {
|
||||||
// Search for column names
|
$result = db2_columns($this->_connection,NULL,$this->_config['connection']['schema'] ? $this->_config['connection']['schema'] : '%',$table,$like);
|
||||||
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);
|
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} 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;
|
$count = 0;
|
||||||
$columns = array();
|
$columns = array();
|
||||||
while ($row = db2_fetch_assoc($result))
|
while ($row = db2_fetch_assoc($result)) {
|
||||||
{
|
|
||||||
list($type, $length) = $this->_parse_type($row['TYPE_NAME']);
|
list($type, $length) = $this->_parse_type($row['TYPE_NAME']);
|
||||||
|
|
||||||
$column = $this->datatype($type);
|
$column = $this->datatype($type);
|
||||||
@ -240,6 +233,10 @@ class Kohana_Database_DB2 extends Database {
|
|||||||
$columns[$row['COLUMN_NAME']] = $column;
|
$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
|
// Save our cache data for next call
|
||||||
if ($this->_config['caching']) {
|
if ($this->_config['caching']) {
|
||||||
Kohana::cache($cache_key,$columns);
|
Kohana::cache($cache_key,$columns);
|
||||||
|
Reference in New Issue
Block a user