Enabled a default model, fixed db2_columns calls to specific tables in schema, fixed exception calls

This commit is contained in:
Deon George 2015-10-09 13:36:01 +11:00
parent 8f82aeb96f
commit bc2d62980c
2 changed files with 21 additions and 9 deletions

View File

@ -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
View 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));
}
}
?>