ZF-12301: how to connect to database

Description

this my controller <?php

class IndexController extends Zend_Controller_Action { public $options; public function init() { /* Initialize action controller here */ $bootstrap = $this->getInvokeArg('bootstrap'); $options = $bootstrap->getOptions(); //echo "

<

pre>"; print_r($options['webhost']);

    $model=new Application_Model_User();
    $model->getdata();



}

public function indexAction()
{

}

}

this my model

<?php

class Application_Model_User extends Zend_Db_Table_Abstract {

public function getdata() { $sql="select * from userdetails"; print_r($this->fetchAll($sql)); }

}

this my application.ini

[production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 includePaths.library = APPLICATION_PATH "/../library" bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" appnamespace = "Application" resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 1 webhost = http://localhost/zend/public/ database.adapter = PDO_MYSQL database.params.host = localhost database.params.username = root database.params.password = root database.params.dbname = zend

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" [staging : production]

[testing : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1

[development : production] phpSettings.display_startup_errors = 1 phpSettings.display_errors = 1 resources.frontController.params.displayExceptions = 1 webhost = http://localhost/zend/public/ database.adapter = PDO_MYSQL database.params.host = localhost database.params.username = root database.params.password = root database.params.dbname = zend

this the error got while i run

http://localhost/zend/public/ Fatal error: Uncaught exception 'Zend_Controller_Response_Exception' with message 'Cannot send headers; headers already sent in /Applications/MAMP/htdocs/zend/application/controllers/IndexController.php, line 12' in /Applications/MAMP/htdocs/zend/library/Zend/Controller/Response/Abstract.php:323 Stack trace: #0 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Response/Abstract.php(341): Zend_Controller_Response_Abstract->canSendHeaders(true) #1 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Response/Abstract.php(768): Zend_Controller_Response_Abstract->sendHeaders() #2 /Applications/MAMP/htdocs/zend/library/Zend/Controller/Front.php(992): Zend_Controller_Response_Abstract->sendResponse() #3 /Applications/MAMP/htdocs/zend/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #4 /Applications/MAMP/htdocs/zend/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #5 /Applications/MAMP/htdocs/zend/public/index.php(25): Zend_Application->run() #6 {main} in /Applications/MAMP/htdocs/zend/library/Zend/Controller/Response/Abstract.php on line 323

please any try to help me. i ma new to zend framework sp please help me thank you.

Comments

I'm closing this ticket as it is a support request, and not an issue with the framework.

Please use the mailing list, or #zftalk on freenode irc for support.

For getting started with Zend Framework with mysql, try Akrabat's tutorial at http://akrabat.com/zft