我的代码是这样子的, echo $sql 能够查到数据 可是只要一fetchAll或者query就报错
$hotel_id=stripslashes($_REQUEST["hotel_id"]);
$sql="select * from seo where url_type='hotel' and url_id='".$hotel_id."'";
这里我把条件改成selecte * from seo 还是报同样的错
echo $sql; echo出来的语句去数据库可以查到数据
$wheres1=$this->seo->fetchAll($sql)->toArray();//这里的seo是我在init函数里初始化的Model,问题就出在这里
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刚开始我以为是这个表名seo与Model名seo冲突 可是我改了以后 还是没用各位高手们啊 帮帮忙啊 我在线等啊·~~~
$hotel_id=stripslashes($_REQUEST["hotel_id"]);
$sql="select * from seo where url_type='hotel' and url_id='".$hotel_id."'";
这里我把条件改成selecte * from seo 还是报同样的错
echo $sql; echo出来的语句去数据库可以查到数据
$wheres1=$this->seo->fetchAll($sql)->toArray();//这里的seo是我在init函数里初始化的Model,问题就出在这里
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刚开始我以为是这个表名seo与Model名seo冲突 可是我改了以后 还是没用各位高手们啊 帮帮忙啊 我在线等啊·~~~
$wheres1=$this->seo->fetchAll()->toArray();public function fetchAll($where = null, $order = null, $count = null, $offset = null) 这一句是它的源码
这个条件 是双条件的···
$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函数有四个参数 第一个参数就是条件了