I am just beginning to use Zend Framework and starting to understand how it works. I have checked the official documentationa and followed several tutorials and most of the examples I have found are quite basic: one or 2 tables (at most) are used in the application and one model is created for each one. No problem there, but right now I am working in a real application where I get my data from a complex sql query that includes several tables (5 to be precise) and one stored procedure. I honestly have no idea on how to proceed with this or even where to start trying.
Should I create a model for each table involved in the query (5 of them), even when I only need 1 or 2 fields from some of them and then try to make a select that works? or Should I create a view on the database (doesn´t sounds so good with the stored procedure) and then base the model on that view? or Should I use a ORM to make my life easier? If so, do you know of any that works properly with Firebird? or do I have no idea and I should do something totally different to those things I mentioned?
UPDATE
By Will's suggestion and checking in Zend's documentation I decided to use an Adapter to make the query directly in SQL format, but it is not quite working yet. What i have so far in my controller is this:
use Zend\Db\Adapter\Adapter as DbAdapter;
use Zend\Db\ResultSet\ResultSet;
...
public function indexAction() {
$db = new DbAdapter(array(
'driver' => 'Pdo',
'dsn' => 'firebird:host=127.0.0.1;port=3050;dbname=C:\\wamp\\www\\Reports\\data\\THdata.GDB',
'username' => 'SYSDBA',
'password' => 'masterkey' ));
$sql = 'SELECT SELITE FROM TILIKAUSI WHERE COMPANYID = 1'; //I am starting with a simple query first.
$sql_result = $db->createStatement($sql, array(125000, 125200))->execute();
if($sql_result->count() > 0){
$results = new ResultSet();
$this->view->data = $results->initialize($sql_result)->toArray();
}
return $this->view;
}
The result is an error like Creating default object from empty value in (Controller path, line: $this->view->data = $results;)
It seems like no values are being returned. Is this an appropiate way of doing this query or am I missing something? Thanks for your help!