1
첫 번째 레코드가 계속 표시됩니다. 그래, 내가 $model[0]
을 썼다는 것을 알았지 만, 왜 제품 ID가 주어진 첫 번째 레코드를 얻는 함수를 사용하지 않았는가? 매개 변수가 무엇이든 관계없이 첫 번째 레코드 만 반환합니다.기준에 올바른 행을 반환하지 않습니다.
컨트롤러 :
foreach ($basket as $item){
if($item->product->store_id==$value){
//here... tried hard coding different things in the params.. doesn't work
$shipping = table::model()->getProductShipRate(322, $from, $to);
$ship_fee = $shipping[0]->ships_to_fee;
//blah blah
print_r($shipping[0]->add_cost); // always give me the first entry.
}
}
모델 :
public function getProductShipRate($pid,$from,$to){ //doesn't do anthing dont know why.
$criteria = new CDbCriteria();
$criteria->condition='product_id="'.$pid.'"';
$criteria->condition='ships_from="'.$from.'"';
$criteria->condition='ships_to="'.$to.'"';
$record =$this->findAll($criteria);
if(!empty($record))
return $record;
}
+1하거나 $ criteria-> PARAMS = 배열을 사용할 수 있습니다;
을하지만 더 나은이 모양이 사용 – NEWBIE