Zend Framework - Where are the queries?

Asked

Viewed 127 times

1

I have an application using Zend Framework, in the structure MVC, I want to know where the queries to the bank are made, I’m a little lost because I never worked with Zend. In my model I urge, for example:

class Cursos extends Zend_Db_Table{

    protected $_name = 'cursos';

    }

but the consultation itself:

select * from cursos

where it is?

1 answer

2

The ideal in the MVC standard is that your queries stay within the Model, to perform this query you mentioned would look like this:

class Cursos extends Zend_Db_Table{

    protected $_name = 'cursos';

    public function getAllCursos() {
        //SELECT * FROM cursos;
        return $this->fetchAll()->toArray();
    }

}

Install the model on the controller and call for the function getAllCursts, will return you an array of all courses.

To perform more elaborate queries, with Where, Join, group, order and etc... Zend_db provides a series of functions to help you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.