[英]zend db error on switching tables Catchable fatal error: Argument 1 passed to __construct() must be an array, object given, called in
In my application I have set up the db connection. 在我的应用程序中,我已经建立了数据库连接。 Now i want to switch tables and i keep getting following error 现在我想切换表,并且不断出现以下错误
Catchable fatal error: Argument 1 passed to Application_Model_PgeSeismicFile::__construct() must be an array, object given, called in /opt/eposdatatransfer/application/models/PgeSeismicFileMapper.php on line 58 and defined in /opt/eposdatatransfer/application/models/PgeSeismicFile.php on line 10
I have two models for the two tables. 我有两个表的两个模型。 i get error when I try to access the second table. 当我尝试访问第二张表时出现错误。 Accessing and setting the 1st table is fine and i do it the same way. 访问和设置第一张表很好,我用相同的方式做。 Here is how I am switching the tables. 这是我切换表格的方式。
private $_dbTable = null;
public function setDbTable($dbTable, $path = false)
{
$project = $_REQUEST['username'];
$filename = $path . "PSDB.db"; //APPLICATION_PATH . "/data/db/".$project."/PSDB.db";
if (!file_exists($filename)) {
//$this->_redirect('/');
// need to redirect and pass eror message for user
throw new Exception("File does not exist");
}
try{
//exit("3");
$dbAdapter = Zend_Db::factory("pdo_sqlite", array("dbname"=> $filename));
}catch (Zend_Db_Adapter_Exception $e) {
// perhaps a failed login credential, or perhaps the RDBMS is not running
var_dump($e);
exit("1");
} catch (Zend_Exception $e) {
// perhaps factory() failed to load the specified Adapter class
var_dump($e);
exit("2");
}
if (is_string($dbTable)) {
print_r($dbAdapter);
$dbTable = new $dbTable($dbAdapter);
$dbTableRowset = $dbTable->find(1);
$user1 = $dbTableRowset->current();
//var_dump($user1);
//exit("hello");
//$row = $user1->findDependentRowset();
}
if (!$dbTable instanceof Zend_Db_Table_Abstract) {
throw new Exception('Invalid table data gateway provided');
}
$this->_dbTable = $dbTable;
//$session = new Zend_Session_Namespace();
//$session->dbAdapter = $this->_dbTable;
//var_dump($this);
//exit();
return $this;
}
public function getDbTable($path = false)
{
if (null === $this->_dbTable) {
$session = new Zend_Session_Namespace();
//$this->setDbTable('Application_Model_PgeSeismicFile',$path);
$this->dbTable = new Application_Model_PgeSeismicFile($session->dbAdapter);
}
return $this->_dbTable;
}
It errors on this line 这条线上有错误
$this->dbTable = new Application_Model_PgeSeismicFile($session->dbAdapter);
In my session i am storing: 在我的会议中,我存储:
$dbAdapter = Zend_Db::factory("pdo_sqlite", array("dbname"=> $filename));
try this 尝试这个
$dbAdapter = Zend_Db::factory("pdo_sqlite", array("dbname"=> $filename));
Zend_Db_Table::setDefaultAdapter($dbAdapter);
$this->dbTable = new Application_Model_PgeSeismicFile;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.