Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework 1.x - How do I get data from database?
    primarykey
    data
    text
    <p><strong>Here is my project structure: <a href="http://img823.imageshack.us/img823/7047/68818300.png" rel="nofollow">http://img823.imageshack.us/img823/7047/68818300.png</a></strong> <br/><br/> I connected to database by using php.ini:</p> <pre><code>[production] phpSetting.display_status_errors = 1 phpSetting.display_errors = 1 bootstrap.path = APPLICATION_PATH "/Bootstrap.php" bootstrap.class = "Bootstrap" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.defaultModule = "front" resources.frontController.baseUrl = "http://localhost:8080/zendfirst/" resources.db.adapter = "PDO_MYSQL" resources.db.params.host = "localhost" resources.db.params.username = "root" resources.db.params.password = "" resources.db.params.dbname = "estore" autoloadernamespaces.extendlib = "ExtendLib_" resources.layout.layout = "index" resources.layout.layoutPath = APPLICATION_PATH "/templates/front/default" [developer : production] phpSetting.display_status_errors = 0 phpSetting.display_errors = 0 </code></pre> <p>I searched on google but there were many ways to do but I don't know how. I'm trying this way but it doesn't work. Here is my model:</p> <pre><code>&lt;?php class Model_User { protected $db; public function __construct() { $this-&gt;db = Zend_Registry::get('db'); } public function listAll() { $sql = $this-&gt;db-&gt;query("SELECT * FROM SanPham ORDER BY Id DESC"); return $sql-&gt;fetchAll(); } } </code></pre> <p>And this is my controller:</p> <pre><code>&lt;?php class IndexController extends Zend_Controller_Action { public function indexAction() { $muser = new Model_User();//error here $data = $muser-&gt;listAll(); echo "&lt;pre&gt;"; print_r($data); echo "&lt;/pre&gt;"; } public function viewAction() { } public function preDispatch() { } } </code></pre> <p>The controller doesn't know what is user model. How should I call model in controller? Here is my project: <a href="https://www.box.com/s/idw5twyyo41yn8gq1kfe" rel="nofollow">https://www.box.com/s/idw5twyyo41yn8gq1kfe</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload