Enabled a default model, fixed db2_columns calls to specific tables in schema, fixed exception calls
This commit is contained in:
parent
8f82aeb96f
commit
bc2d62980c
@ -37,7 +37,6 @@ class Kohana_Database_DB2 extends Database {
|
||||
'port' => '',
|
||||
'password' => '',
|
||||
'persistent' => FALSE,
|
||||
'schema' => '',
|
||||
));
|
||||
|
||||
// Get user login details from user session - these are set by login
|
||||
@ -75,9 +74,8 @@ class Kohana_Database_DB2 extends Database {
|
||||
$e->getCode());
|
||||
}
|
||||
|
||||
if (! $this->_connection) {
|
||||
throw new Database_Exception('Connection to DB2 failed? (:error)', array(':error'=>db2_conn_errormsg()));
|
||||
}
|
||||
if (! $this->_connection)
|
||||
throw new Database_Exception('Connection failed (:error)',array(':error'=>db2_conn_errormsg()),db2_conn_error());
|
||||
|
||||
// \xFF is a better delimiter, but the PHP driver uses underscore
|
||||
$this->_connection_id = sha1($hostname.'_'.$username.'_'.$password);
|
||||
@ -129,9 +127,7 @@ class Kohana_Database_DB2 extends Database {
|
||||
Profiler::delete($benchmark);
|
||||
}
|
||||
|
||||
throw new Database_Exception(':error [ :query ]',
|
||||
array(':error' => db2_stmt_errormsg(), ':query' => $sql),
|
||||
db2_stmt_error());
|
||||
throw new Database_Exception(':error [ :query ]',array(':error' => db2_stmt_errormsg(), ':query' => $sql),db2_stmt_error());
|
||||
}
|
||||
|
||||
if (isset($benchmark))
|
||||
@ -182,10 +178,10 @@ class Kohana_Database_DB2 extends Database {
|
||||
{
|
||||
// Find all column names
|
||||
try {
|
||||
$result = db2_columns($this->_connection,NULL,'%',$table);
|
||||
$result = db2_columns($this->_connection,NULL,$this->_config['connection']['schema'] ? $this->_config['connection']['schema'] : '%',$table);
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new Kohana_Exception('Unable to show DB Columns :table (:connection)',array(':table'=>$table,':connection'=>$this->_connection));
|
||||
throw new Database_Exception('Unable to obtain Columns for :table [:error]',array(':table'=>$table,':error' => db2_stmt_errormsg()),db2_stmt_error());
|
||||
}
|
||||
}
|
||||
|
||||
|
16
classes/Model/DEFAULT.php
Normal file
16
classes/Model/DEFAULT.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* @package Kohana/Database
|
||||
* @category Models
|
||||
* @author Deon George
|
||||
* @copyright (c) 2015 Deon Geoge
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
|
||||
final class Model_DEFAULT extends ORM_DB2 {
|
||||
public static function _default($class) {
|
||||
return eval(sprintf('class %s extends ORM_DB2 {};',$class));
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user