我正在玩一个 zencart 试图让它做我想做的事,但我对谷歌的想法已经用完了。
当我使用 zencart 函数查询数据库时,软件返回一个对象,如下所示:
queryFactoryResult Object
(
[is_cached] =>
[resource] => Resource id #117
[cursor] => 11
[EOF] =>
[fields] => Array
(
[products_id] => 5582
[products_description] => description here
[products_name] => Lucky magnet – Each petal...
[products_type] => 1
[products_quantity] => 0
[products_image] => EachPetalMag.jpg
[products_price] => 3.4000
[products_status] => 1
[products_ordered] => 14
[master_categories_id] => 21
[supplier_id] => 7
)
)
在我可以做任何其他事情之前,我必须循环一次以计算有多少 master_categories:
while (!$products->EOF) {
$products_count++;
$supcats[$products->fields['master_categories_id']] = $products->fields['master_categories_id'];
$products->MoveNext();
}
然后我需要使用上面的while循环再次循环对象,我试过了:
reset($products);
和
$products->EOF = FALSE;
但他们不工作。有没有办法做到这一点而不必再次发送查询?