April 4, 2007

Selecting no fields of a table joined in a Zend_Db_Select

Filed under: PHP — Marcus @ 1:00 pm

I want to be able to use joins to limit the result set I get from a query, but I don’t want to actually select any values from the table I’m joining on, merely use it for making sure what I get back is what I asked for. However it seems there’s no way of saying “don’t select ANY columns from this joined table”.

Code (php)
  1.  
  2. $select->from(‘registereduser’, ‘*’)
  3. ->joinInner(’sessionbooking’, ‘registereduser.id=sessionbooking.userid’,
  4. new Zend_Db_Expr(’sessionbooking.status as status’))
  5. ->joinInner(’sessiontime’, ’sessiontime.id=sessionbooking.sessionid’, )
  6. ->where(’sessiontime.id=?’);
  7.  

So far I’ve resorted to adding something into Zend_Db_Select::_tableCols() to check if the $cols is empty or null and returning if that’s the case. Am I just going about constructing my query incorrectly?

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

.

Powered by WordPress