Results 1 to 7 of 7

Thread: Zend_Db_Select with a join?

  1. #1
    nozavroni is offline Junior Member
    Join Date
    Oct 2007
    Posts
    2

    Default Zend_Db_Select with a join?

    I'm trying to use Zend_Paginator to paginate my members table with the DbSelect adapter. In order to use it, you have to provide a Zend_Db_Select object. I am trying to do this, but I need to do a query like this:

    Code:
                SELECT members.*
                FROM
                    members,
                    members_classifications
                WHERE
                    members_classifications.mem_id = members.id
                AND
                    members_classifications.class_id = 123
    How would I do something like this, but inside of the select() statement. How would I do it?

    I tried this:

    [php] $select->join(array('mc' => 'members_classifications'), 'mc.mem_id = members.id');
    $select->where('mc.class_id = ?', $params['class']);[/php]

    But it gave me this exception:

    Code:
    Exception type: Zend_Db_Table_Select_Exception
    Message: Select query cannot join with another table
    Last edited by nozavroni; 08-13-2008 at 06:27 PM.

  2. #2
    OmeZ is offline Junior Member
    Join Date
    Aug 2008
    Posts
    6

    Default

    set integrity check flag to false, it should be enought

  3. #3
    pashazend is offline Junior Member
    Join Date
    Jul 2008
    Posts
    2

    Question Same problems..

    i have a same problem with Zend_Db_Select..
    i use Zend_Db_Table, the name is EnginePosts and i try to join the table like this..

    $this->table = new EnginePosts();
    $select = $this->table->select()->setIntegrityCheck(false);
    $select->joinLeft("engine_term_relation","term_rel_id_ob j = post_id");
    $resultset = $this->table->fetchAll($select);


    and i get this message:

    Uncaught exception 'Zend_Db_Table_Row_Exception' with message 'Specified column "post_date" is not in the row'........
    Last edited by pashazend; 08-15-2008 at 06:11 AM.

  4. #4
    OmeZ is offline Junior Member
    Join Date
    Aug 2008
    Posts
    6

    Default

    you should specify table name in row definition, I guess. What table structure you have?

  5. #5
    pashazend is offline Junior Member
    Join Date
    Jul 2008
    Posts
    2

    Default detail

    this is my table structure :
    `post_id` int(11) NOT NULL,
    `post_title` text,
    `post_content` text,
    `post_date` datetime default NULL,
    `post_status` varchar(20) default NULL,
    `post_guid` varchar(200) default NULL,
    `post_type` varchar(10) default NULL

    and i write this code :

    class EnginePosts extends Zend_Db_Table
    {
    protected $_name = 'engine_post';
    }

    in EnginePosts.php

  6. #6
    OmeZ is offline Junior Member
    Join Date
    Aug 2008
    Posts
    6

    Default

    Quote Originally Posted by pashazend View Post
    this is my table structure :
    `post_id` int(11) NOT NULL,
    `post_title` text,
    `post_content` text,
    `post_date` datetime default NULL,
    `post_status` varchar(20) default NULL,
    `post_guid` varchar(200) default NULL,
    `post_type` varchar(10) default NULL

    and i write this code :

    class EnginePosts extends Zend_Db_Table
    {
    protected $_name = 'engine_post';
    }

    in EnginePosts.php
    and with what table you join this?

  7. #7
    dudu is offline Junior Member
    Join Date
    Jun 2008
    Posts
    5

    Default

    maybe you can do it like this:
    [PHP]
    $select->from($this->members,"*");
    $select->join($this->members_classifications,$this->memebers_classifications.'.id='.$this->members.'.id','*');
    $select->where("$this->members_classifications.class_id=?","123");
    [/PHP]
    it's just my opinion.

Similar Threads

  1. Zend_db_Select
    By dbanton in forum Databases
    Replies: 1
    Last Post: 03-28-2010, 01:07 PM
  2. Zend_DB_Select Problem
    By j0118119 in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 10-12-2009, 08:23 AM
  3. Zend_db_select exception
    By petran in forum General Q&A on Zend Framework
    Replies: 0
    Last Post: 09-07-2008, 10:46 PM
  4. Zend_Db_Select or Zend_Db_Adapter
    By dele454 in forum Databases
    Replies: 2
    Last Post: 07-18-2008, 05:08 AM
  5. join,left join and right join in zend_db_table
    By aniltc in forum Databases
    Replies: 0
    Last Post: 05-28-2008, 06:00 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
  •