+ Reply to Thread
Results 1 to 3 of 3

Thread: problem with an sql JOIN

  1. #1
    derrida is offline Member
    Join Date
    Sep 2009
    Posts
    99

    Default problem with an sql JOIN

    hi

    i need to join 2 tables. i cannot make it the zend way so i decided to use regular sql, like so. in my model i have this method:
    Code:
        public function getallposts()
        {
            $select = "SELECT posts.id,posts.category_id,posts.date,categories.id,categories.title 
     FROM posts LEFT JOIN categories 
    	ON posts.category_id = categories.id";
            
            $result = $this->fetchAll($select);
            
            return $result;
        }
    i get this error:
    Message: SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)

    what am i missing here? and maybe someone can help me with the way to join with zend way?

    best regards

    ron

  2. #2
    derrida is offline Member
    Join Date
    Sep 2009
    Posts
    99

    Default manage to fixed it

    hi

    saw this way and implemented it to my situation:
    Code:
    $select = $this->select(); 
            $select->setIntegrityCheck(false); 
            $select->from('posts', 'posts.*'); 
            $select->joinLeft('categories', 'posts.category_id = categories.id');
    the setIntegrityCheck is crucial, set it to false.

  3. #3
    lion21 is offline Junior Member
    Join Date
    Apr 2009
    Posts
    13

    Default

    Quote Originally Posted by derrida View Post
    hi

    saw this way and implemented it to my situation:
    Code:
    $select = $this->select(); 
            $select->setIntegrityCheck(false); 
            $select->from('posts', 'posts.*'); 
            $select->joinLeft('categories', 'posts.category_id = categories.id');
    the setIntegrityCheck is crucial, set it to false.
    wat this "setIntegrityCheck" function is for ??

+ Reply to Thread

Similar Threads

  1. Zend_DB join
    By nickleplated in forum Databases
    Replies: 0
    Last Post: 11-23-2009, 09:39 AM
  2. Problem with left join
    By nogenius in forum Databases
    Replies: 2
    Last Post: 05-05-2009, 09:59 PM
  3. Zend_db_table and join
    By zf123 in forum General Q&A on Zend Framework
    Replies: 2
    Last Post: 11-21-2008, 11:11 AM
  4. (another) zend_paginator + join problem
    By allennh in forum Databases
    Replies: 5
    Last Post: 11-04-2008, 05:51 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