當我運行Product.php
這是模型文件時出現此錯誤,並且出現此錯誤CDbCommand未能執行SQL語句:SQLSTATE [42S22]:未找到列:1054'where子句'中的未知列'product_profile.price'
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'product_profile.price' in 'where clause'. The SQL statement executed was: SELECT COUNT(*) FROM
product
t
INNER JOIN product ON product_profile.product_id = t.product_id WHERE product_profile.price >=0 AND product_profile.price <=100
查詢的代碼如下
if (!empty($_POST['price'])) {
$price = explode(",", $_POST['price']);
$criteria = new CDbCriteria;
$criteria->select = 'product_profile.price,product_profile.product_id';
$criteria->join.='INNER JOIN product ON product_profile.product_id = t.product_id';
$criteria->condition = " product_profile.price BETWEEN 1 AND 100";
// $criteria->condition = 'product_profile.price >=0 AND product_profile.price <=100';
$criteria->addInCondition("product_profile.price",$price);
}
和你的問題是什麼? – 2014-03-14 07:16:17
@Gumbo你在哪裏更快的代碼;) – 2014-03-14 07:19:04