Zend Framework - Where are query queries?

1

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

class Cursos extends Zend_Db_Table{

    protected $_name = 'cursos';

    }

but the query itself:

select * from cursos

Where is it?

    
asked by anonymous 31.10.2016 / 01:29

1 answer

2

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

class Cursos extends Zend_Db_Table{

    protected $_name = 'cursos';

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

}

Instantiate the model in the controller and call the getAllCourses function, it will return an array with all the courses.

For more elaborate queries, with where, join, group, order, etc ... Zend_Db provides a number of functions to help you.

    
31.10.2016 / 14:28