Results 1 to 1 of 1

Thread: Using Zend_Db_Table to return referenced values

  1. #1
    dele454's Avatar
    dele454 is offline Member
    Join Date
    Jun 2008

    Default Using Zend_Db_Table to return referenced values


    I have two tables: Venue & VenueCategory table with def such as

    Venue(VenueID, VenueName, CategoryID)
    VenueCategory(CategoryID, CategoryName)

    I want to convert my query in sql to using the Zend_Db_Table:

    SELECT v.VenueName, c.Category FROM Venue v LEFTJOIN VenueCategory ON
    v.CategoryID = c.CategoryID;

    I have my model as:

            class Venues extends Zend_Db_Table_Abstract {
               //protected $_rowClass = 'Venue';
               protected $_primary = 'VenueID';
               protected $_name = 'venue';
               protected $_referenceMap     = array(
                    'Category'         => array(
                                        'columns'       => 'CategoryID',
                                            'refTableClass' => 'venuecategory',
                                            'refColumns'    => 'CategoryID'
                                     'Area'             => array(
                                        'columns'       => 'AreaID',
                                            'refTableClass' => 'area',
                                            'refColumns'    => 'AreaID',
                    // returns all venues in the db
                    public function getAllVenues() {
                         $sql    = $this->select();
                                  ->joinLeftUsing('venuecategory', 'CategoryID');
                        $result = $this->fetchAll($sql)->toArray();
                        return $result;

    The Question is how can I join the two tables like the query above to return all venues with matching category names. I want to use the joinLeftUsing() function from the the Zend_Db_Select class. The Reference Guide only gives samples with using joins on a rowset.

    At the moment the page is blank in my view script - i know something is wrong but i cant figure it out. How can i use those arrays declared for the tables in my query statement?

    Please help is needed.

    Last edited by dele454; 07-28-2008 at 01:38 PM.

Similar Threads

  1. Replies: 0
    Last Post: 06-15-2010, 09:25 PM
  2. Return to URL after login
    By jsuggs in forum Model-View-Controller (MVC)
    Replies: 2
    Last Post: 10-02-2009, 03:15 PM
  3. Return to page on error
    By Bjorn121 in forum Model-View-Controller (MVC)
    Replies: 1
    Last Post: 07-12-2009, 08:15 AM
  4. Help with _getAllParams and Multi-Select Return Values
    By johnlamont in forum Model-View-Controller (MVC)
    Replies: 3
    Last Post: 06-21-2009, 01:04 PM
  5. PDO Stored Procedure Return Values
    By rayne5446 in forum Databases
    Replies: 0
    Last Post: 06-12-2009, 02:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts