我的代码是这样子的, 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
解决方案 »
- 用fsockopen POST数据大问题,有=号就读取错误!!
- PHP抓取页面后正则截取值,只要中间的值
- 求教啊~!~!!为什么我数据库里面的值不能取出来啊?
- 表单参数连续传递问题
- php 读取 mysql 表中的double数据,去掉多余的0
- 研究了一天无结果:代码转换成UTF8后出现"未结束的字符串常量"错误.
- php文件中的中文乱码该如何解决
- 这是什么错误(Client does not support authentication protocol requested by server; consider upgrading MySQL client)?
- PHP5 的 preg_replace 比旧版本慢了好多啊
- 怎样实现发断消息?
- php连接远程数据库(mssql 2000)失败?但连接本地成功!
- 求一正则优化
$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函数有四个参数 第一个参数就是条件了