문제

나는 테이블이있다 (product_shoppingcart) 4 개의 열로 :

id, product_id, shoppingcart_id, product_quantity.

나는 Kohana의 ORM을 사용하고 있습니다.

나는 모든 행을 반환하는 검색 쿼리를 작성하고 싶습니다. shoppingcart_id 열에는 1 (예 : 1)을 포함합니다.

나는 이미 시도했다 :

$arr = ORM::factory('product_shoppingcart')->where('shoppingcart_id',$shoppingcartID)->find_all();

그러나 그것은 작동하지 않습니다.

누구든지 나를 도와 줄 수 있습니까?

도움이 되었습니까?

해결책

예제 코드가 작동해야하지만 문제는 결과 세트를 반복하지 않는다는 것입니다.

$results = ORM::factory('product_shoppingcart')
           ->where('shoppingcart_id', $shoppingcartID)
           ->find_all();
foreach ($results as $product_shoppingcart) {
  print Kohana::debug($product_shoppingcart->as_array());
}

해당 ID가있는 행이 둘 이상인 경우 $ 결과의 결과 반복자를 제공하여 Foreach 루프와 함께 걸어갑니다. 여전히 작동 할 수 없다면 비슷한 작업 코드의 예가 많이 있습니다.

다른 팁

다음은 다음과 같습니다.

$arr = ORM::factory('product_shoppingcart')->where(
                    'shoppingcart_id',"=",$shoppingcartID)->find_all();

당신의 테이블이 "product_shoppingcarts"가되어서는 안됩니다. 아니면 내가 뭔가를 놓치고 있습니까?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top