myprojekt/application/controllers/IndexController.php:
<?php class IndexController extends Zend_Controller_Action { function init() { $this->view->baseUrl = $this->_request->getBaseUrl(); Zend_Loader::loadClass('Oferty'); } function indexAction() { $offer = new Oferty(); $result = $offer->fetchAll(); $this->view->offers = $result; // $sql = 'SELECT * FROM ns_offer'; // $result = $offer->fetchAll($sql); } ?>
myprojekt/application/models/Oferty.php :
<?php class Oferty extends Zend_Db_Table { protected $_name = 'ns_offer'; } ?>
myproject/index.php :
<?php date_default_timezone_set('Europe/London'); . PATH_SEPARATOR . './application/models/' include "Zend/Loader.php"; Zend_Loader::loadClass('Zend_Controller_Front'); Zend_Loader::loadClass('Zend_Config_Ini'); Zend_Loader::loadClass('Zend_Registry'); Zend_Loader::loadClass('Zend_Db'); Zend_Loader::loadClass('Zend_Db_Table'); // load configuration $config = new Zend_Config_Ini('./application/config.ini', 'general'); $registry = Zend_Registry::getInstance(); $registry->set('config', $config); // setup database $db = Zend_Db::factory( $config->db->adapter, $config->db->config->toArray() ); Zend_Db_Table::setDefaultAdapter($db); // setup controller $frontController = Zend_Controller_Front::getInstance(); $frontController->throwExceptions(true); $frontController->setControllerDirectory('./application/controllers'); // run! $frontController->dispatch(); ?>