Thread: Models in Zend
View Single Post
02-09-2011, 12:44 PM
#1
Hero is offline Hero
Hero's Avatar
Status: Very much the flyest.
Join date: Mar 2006
Location: Belgium
Expertise:
Software:
 
Posts: 1,171
iTrader: 1 / 100%
 

Hero is on a distinguished road

  Old  Models in Zend

Hey guys,

I'm working on a website in Zend, and so far I'm not really liking this framework. There's several things that bug me, when I compare it with CI, and their documentation isn't half as good.


One of the problems for me, are the models. Zend says you're supposed to implement those yourself, and that you're free in how to do this.

What I've done so far, is extend my models with Zend_Db_Table_Abstract. And my models are named after my database tables (Model_Table_User for users, Model_Table_Post for posts..)

Problem is that there are limitations to the Zend_Db_Table. For example, it isn't possible to use sql joins, because then you would end up selecting columns that don't exist in a specific table. So I end up doing my join selects like this:

Code:
	$db = Zend_Registry::get('db');
	$query = "SELECT tag_name FROM tags t JOIN posts_tags pt ON pt.tag_id = t.tag_id where pt.post_id = ?";
	$results = $db->query($query, array($postid));
	$tags = $results->fetchAll();
This works, but my problem is, that this is coming from my Controller. It defeats the whole purpose of the M in MVC if I'm addressing my database from the Controller.

Any suggestions how to go about this?