我有一个表(product_shoppingcart)与4列:

id, product_id, shoppingcart_id, product_quantity.

我使用的Kohana的ORM。

我想要写返回其中shoppingcart_id列包含所有行的搜索查询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