我的代码是这样子的, 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
$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
$sql="select * from seo where url_type='hotel' and url_id='".$hotel_id."'";
$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函数有四个参数 第一个参数就是条件了