我的代码是这样子的, echo $sql 能够查到数据 可是只要一fetchAll或者query就报错  
     $hotel_id=stripslashes($_REQUEST["hotel_id"]);
     $hotel_name=stripslashes($_REQUEST["hotel_name"]);
    
     $whereh=$this->hotel->getAdapter()->quoteInto("hotel_id=?",$hotel_id);
     $wherem=$this->menu->getAdapter()->quoteInto("hotel_name=?",$hotel_name);
     $wheret=$this->tag_list->getAdapter()->quoteInto("hotel_name=?",$hotel_name);
    
    
     //$sql="select * from seo where url_id='".$hotel_id ."' and url_type='hotel'";
     //$sql="select * from seo where url_id=$hotel_id and url_type='hotel'";
     //$sql="select * from seo where url_type='hotel' and url_id=".$hotel_id;
     $sql="select * from seo where url_type='hotel' and url_id='".$hotel_id."'";
     echo $sql;
     $wheres1=$this->seo->fetchAll($sql)->toArray();
     print_r($wheres1);而且报的错误很怪异  提示找不到column(s)' 这一列 我明明查都没查这一列 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)' in
D:\wamp\www\daoxila\application\controllers\admin\HotelController.php(128): Zend_Db_Table_Abstract->fetchAll('select * from s...') # in

解决方案 »

  1.   

    seo是我在初始化init里面配置的Model名
      

  2.   

    现在我就算是$sql="select * from seo";都会报错啊   刚开始我以为是这个表名seo与Model名冲突  可是我改了以后 还是没用啊~~~·
      

  3.   

    $wheres1=$this->seo->fetchAll()->toArray(); 为空试下
      

  4.   

    为空能查到  但是并不解决问题啊 当我加条件就不行了 我也知道如果只要加一个条件的话 用quoteinto就行了  我是要查双条件··
    $sql="select * from seo where url_type='hotel' and url_id='".$hotel_id."'";
      

  5.   

    你自己连手册都不看
    $table->fetchAll($where, $order, $count, $offset);<?php
    class RoundTable extends Zend_Db_Table {}$table = new RoundTable();
    $db = $table->getAdapter();// SELECT * FROM round_table
    //     WHERE noble_title = "Sir"
    //     ORDER BY first_name
    //     LIMIT 10 OFFSET 20$where = $db->quoteInto('noble_title = ?', 'Sir');
    $order = 'first_name';
    $count = 10;
    $offset = 20;$rowset = $table->fetchAll($where, $order, $count, $offset);
    ?>
    fetchAll函数有四个参数 第一个参数就是条件了