2
내가 원하는 것을하기 위해 노력하고있는 zencart로 놀고 있지만 Google에 대한 아이디어가 부족합니다. 나는 소프트웨어가 보이는 개체를 반환 zencart 기능을 사용하여 DB를 조회 할 때개체를 두 번 반복 - php
처럼 :
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;
하지만 그들은 작동하지 않습니다. 쿼리를 다시 보내지 않고도이 작업을 수행 할 수 있습니까? (ROW_NUMBER 다시 변수를 통해 루프에
reset($products);
queryFactoryResult-> 이동을 사용 : 그것은 배열이 아니다으로 선 장바구니 queryFactoryResult에
데이터를 배열에 저장하고 두 번째로 해당 배열을 반복 해 보았습니까? 예를 들어, PDO는 결과 세트 커서를 되 감을 수 없습니다. – rodneyrehm
데이터를 한 번 단계별로 실행할 수 있습니다. @rodneyrehm이 제안하는대로 master_categories 수를 계산하고 데이터를 배열로 복사하십시오. – andrewsi
ZenCart에는 다시 쿼리하거나 배열에 정보를 저장하지 않고 포인터를 시작 부분으로 다시 설정하는 기능이 없습니다. 결과 집합을 여러 번 반복 할 필요가없는 논리를 작성하는 더 좋은 방법이 있어야합니다. – Quantastical