ZF-2393: Instantiation of model fails with "Call to a member function describeTable() on a non-object in .../Zend/Db/Table/Abstract.php on line 595"
Description
Hi,
I am currently developing under Mac OS X 10.5 with: MySQL 5.0.41 Apache 2.0.59 PHP 5.2.3
I am holding my connection details to the database in a config.xml (works) and opening a connection (it's PDO_MYSQL and was working in manual tests) via a bootstrap file.
$db = Zend_Db::factory($config->database->type, $config->database->toArray());
Zend_Db_Table::setDefaultAdapter($db);
My model looks like this:
<?php
class Forum extends Zend_Db_Table
{
protected $_name = 'forum';
}
?>
My controller is like this:
<?php
class IndexController extends Zend_Controller_Action
{
public function init()
{
$this->view->baseUrl = $this->_request->getBaseUrl();
Zend_Loader::loadClass('Forum');
}
public function indexAction()
{
$this->view->title = "Index";
$forum = new Forum();
$this->view->forums = $forum->fetchAll();
}
}
?>
This results in
Fatal error: Call to a member function describeTable() on a non-object in /Applications/MAMP/htdocs/Zend/Db/Table/Abstract.php on line 595
A dump of $db in the bootstrap file:
object(Zend_Db_Adapter_Pdo_Mysql)#16 (9) {
["_pdoType:protected"] => string(5) "mysql"
["_numericDataTypes:protected"] => array(16) {
[0] => int(0)
[1] => int(1)
[2] => int(2)
["INT"] => int(0)
["INTEGER"] => int(0)
["MEDIUMINT"] => int(0)
["SMALLINT"] => int(0)
["TINYINT"] => int(0)
["BIGINT"] => int(1)
["SERIAL"] => int(1)
["DEC"] => int(2)
["DECIMAL"] => int(2)
["DOUBLE"] => int(2)
["DOUBLE PRECISION"] => int(2)
["FIXED"] => int(2)
["FLOAT"] => int(2)
}
["_config:protected"] => array(7) {
["type"] => string(9) "PDO_MYSQL"
["host"] => string(9) "localhost"
["username"] => string(11) "root"
["password"] => string(10) "****"
["dbname"] => string(13) "renaissance_1"
["options"] => array(2) {
["caseFolding"] => int(0)
["autoQuoteIdentifiers"] => bool(true)
}
["driver_options"] => array(0) {
}
}
["_fetchMode:protected"] => int(2)
["_profiler:protected"] => object(Zend_Db_Profiler)#20 (4) {
["_queryProfiles:protected"] => array(0) {
}
["_enabled:protected"] => bool(false)
["_filterElapsedSecs:protected"] => NULL
["_filterTypes:protected"] => NULL
}
["_defaultProfilerClass:protected"] => string(16) "Zend_Db_Profiler"
["_connection:protected"] => NULL
["_caseFolding:protected"] => int(0)
["_autoQuoteIdentifiers:protected"] => bool(true)
}
I can reproduce this error developing under Mac OS X 10.5 and Windows XP Professional SP2 (xampplite) with both Zend Framework 1.0.3 and the SVN trunk version.
Please contact me for further information.
Comments
Posted by Sascha Fröhlich (sascha) on 2008-01-07T13:37:06.000+0000
Sorry, got confused because of the error page shown after posting the issue. It's a duplicate and can be deleted.
Posted by Darby Felton (darby) on 2008-02-08T14:16:22.000+0000
Resolved as duplicate of [ZF-2244]
Posted by Wil Sinclair (wil) on 2008-12-17T13:44:25.000+0000
Bookkeeping. Closing and assigning all old unassigned issues. The only unassigned issues should be new and unreviewed.