This is probably an easy question. If I call Cities::getName(), I get the following error. I'm probably using this the wrong way, but I don't see what's wrong. In Eclipse, the method fetchRow does appear.
Fatal error: Uncaught exception 'Zend_Controller_Action_Ex
ception'
with message 'Method "fetchRow" does not exist and was not trapped in __call()' in D:\web\test\library\Zend\C
ontroller\
Action.php
:478
Stack trace:
#0 [internal function]: Zend_Controller_Action->__
call('fetc
hRow', Array)
#1 D:\web\test\application\de
fault\mode
ls\Cities.
php(8): AccommodationsController->
fetchRow('
id = 2223')
#2 D:\web\test\application\de
fault\cont
rollers\Ac
commodatio
nsControll
er.php(28)
: Cities->getName(2223)
#3 D:\web\test\library\Zend\C
ontroller\
Action.php
(503): AccommodationsController->
detailActi
on()
#4 D:\web\test\library\Zend\C
ontroller\
Dispatcher
\Standard.
php(285): Zend_Controller_Action->di
spatch('de
tailAction
')
#5 D:\web\test\library\Zend\C
ontroller\
Front.php(
934): Zend_Controller_Dispatcher
_Standard-
>dispatch(
Object(Zen
d_Controll
er_Request
_Http), Object(Zend_Controller_Res
ponse_Http
))
#6 D:\web\test\public\index.p
hp(29): Zend_Controller_Front->dis
patch()
#7 {main}
thrown in D:\web\test\library\Zend\C
ontroller\
Action.php
on line 478
<?php
// Cities.php
class Cities extends Zend_Db_Table_Abstract
{
protected $_name = 'cities';
function getName($id)
{
return $this->fetchRow('id = ' . $id)->name;
}
}
?>
<?php
// AccommodationsController.php
class AccommodationsController extends Zend_Controller_Action
{
function detailAction()
{
$view = new Accommodations();
$id = (int) $this->_request->getParam('id');
$row = $view->fetchDetails($id);
$this->view->city = Cities::getName($id);
}
}
Select all
Open in new window
Open in new window