How to create WHERE IN clause with Zend_Db_Select

前端 未结 6 1485
-上瘾入骨i
-上瘾入骨i 2021-02-01 00:27

So I am trying to accomplish something like this:

SELECT * FROM table WHERE status_id IN (1,3,4);

using Zend_Db_Select... can\'t find how to do

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-01 00:45

    This solution works well with zf2     
     $ids = array('1', '2', '3', '4', '5', '6', '7', '8');
     $select->where(array("app_post_id"=> $ids));
    

    or

     $ids = array('1', '2', '3', '4', '5', '6', '7', '8');
        $sql = new Sql($this->adapter);
            $select = $sql->select();
            $select->from('app_post_comments');
            $select->where(array("app_post_id"=> $ids));
    
    //        echo $select->getSqlString($this->adapter->getPlatform());
    //        exit;
            $statement = $sql->prepareStatementForSqlObject($select);
            $result = $statement->execute();
            $resultSet = new ResultSet();
            $resultSet->initialize($result);
            $resultSet->buffer()->toArray();
            echo '
    ';
            print_r($resultSet);
            exit;
            return $resultSet;
    

提交回复
热议问题