Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 1297 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Models in Zend

Thread title: Models in Zend
Reply    
    Thread tools Search this thread Display Modes  
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?

02-22-2011, 07:26 PM
#2
Enfernikus is offline Enfernikus
Status: I'm new around here
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 20
iTrader: 1 / 100%
 

Enfernikus is on a distinguished road

  Old

Your models don't necessarily need to extend the Zend_Db_Table_Abstract object at all. Conversely if the class provided by Zend does everything you want except for that minor inconvenience then simply fetch the DB object in what ever method it is that you need to join on.

Also, we'd need more information on your database schema and the like in order to make a better recommendation on how to plan your models.

On a personal note, I think Zend is vastly superior to CI.

Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed