I have a code segment from OSCommerce like
while ( $product_array = tep_db_fetch_array($this->products_sql)) {
// do some stuff
}
Further to a request for more information, the full function leading prior to the code in question is shown below.
function get_next_product() {
global $Count, $shoppingCart;
if ($Count && ($this->Products >= $Count)) {
return NULL;
}
$product = NULL;
while ($product_array = tep_db_fetch_array($this->products_sql)) {
$GLOBALS['exporter_module']->checkUsedMemory();
$GLOBALS['shoppingCart']->processProductData($product_array);
foreach ($this->values as $valueName => $valuesArr) {
$product_array[$valueName] = $valuesArr[$product_array['products_id']];
}
$product = $product_array;
$product_array['id'] = $product_array['products_id'];
$product['id'] = $product_array['products_id'];
$product['quantity'] = $product_array['products_quantity'];
// get special price
$special_price = $this->getSpecial($product_array);
if (null !== $special_price['price']) {
$product['price'] = $special_price['price'];
$_product['is_special'] = 1;
} else {
$product['price'] = $product_array['products_price'];
$product['is_special'] = 0;
// Include in Base Price, When Priced by Attributes.
if (isset($product['products_priced_by_attribute'])
&& $product['products_priced_by_attribute'] == 1
&& $product['products_price'] == 0
&& $product['products_price_sorter'] != 0) {
$product['price'] = $product['products_price_sorter'];
$product_array['products_price'] = $product['products_price_sorter'];
}
}
}
Based on information found on the zen cart wiki I changed that for Zen Cart to
while (!$product_array->EOF) {
// do some stuff
$product_array->MoveNext();
}
and now get a Fatal Error: Call to a member function MoveNext() on array $this->products_sql is the content of a function found elsewhere in the same file. Yet even this isn't the actual sql query.
function get_products()
{
$this->products_sql = $this->select_products($this->options['categories'], $this->options['language'], $this->options['quantities'], $this->options['withzero'], $this->options['stockout'], $this->options['sub']);
}
I figured it would help if you knew what $this->products_sql used in the original code contained, so the var_dump is shown below.
object(queryFactoryResult)#47 (10) {
["EOF"]=>
bool(false)
["cursor"]=>
int(0)
["fields"]=>
array(49) {
["products_id"]=>
string(1) "1"
["products_type"]=>
string(1) "1"
["products_quantity"]=>
string(2) "30"
["products_model"]=>
string(8) "MG200MMS"
["products_image"]=>
string(19) "matrox/mg200mms.gif"
["products_price"]=>
string(8) "299.9900"
["products_virtual"]=>
string(1) "0"
["products_date_added"]=>
string(19) "2003-11-03 12:32:17"
["products_last_modified"]=>
string(19) "2004-04-26 23:57:34"
["products_date_available"]=>
NULL
["products_weight"]=>
string(2) "23"
["products_status"]=>
string(1) "1"
["products_tax_class_id"]=>
string(1) "1"
["manufacturers_id"]=>
string(1) "1"
["products_ordered"]=>
string(1) "2"
["products_quantity_order_min"]=>
string(1) "1"
["products_quantity_order_units"]=>
string(1) "1"
["products_priced_by_attribute"]=>
string(1) "0"
["product_is_free"]=>
string(1) "0"
["product_is_call"]=>
string(1) "0"
["products_quantity_mixed"]=>
string(1) "0"
["product_is_always_free_shipping"]=>
string(1) "0"
["products_qty_box_status"]=>
string(1) "1"
["products_quantity_order_max"]=>
string(1) "0"
["products_sort_order"]=>
string(1) "0"
["products_discount_type"]=>
string(1) "0"
["products_discount_type_from"]=>
string(1) "0"
["products_price_sorter"]=>
string(8) "299.9900"
["master_categories_id"]=>
string(1) "4"
["products_mixed_discount_quantity"]=>
string(1) "1"
["metatags_title_status"]=>
string(1) "0"
["metatags_products_name_status"]=>
string(1) "0"
["metatags_model_status"]=>
string(1) "0"
["metatags_price_status"]=>
string(1) "0"
["metatags_title_tagline_status"]=>
string(1) "0"
["language_id"]=>
string(1) "1"
["products_name"]=>
string(15) "Matrox G200 MMS"
["products_description"]=>
string(1159) "Reinforcing its position as a multi-monitor trailblazer, Matrox Graphics Inc. has once again developed the most flexible and highly advanced solution in the industry. Introducing the new Matrox G200 Multi-Monitor Series; the first graphics card ever to support up to four DVI digital flat panel displays on a single 8" PCI board.<br /><br />With continuing demand for digital flat panels in the financial workplace, the Matrox G200 MMS is the ultimate in flexible solutions. The Matrox G200 MMS also supports the new digital video interface (DVI) created by the Digital Display Working Group (DDWG) designed to ease the adoption of digital flat panels. Other configurations include composite video capture ability and onboard TV tuner, making the Matrox G200 MMS the complete solution for business needs.<br /><br />Based on the award-winning MGA-G200 graphics chip, the Matrox G200 Multi-Monitor Series provides superior 2D/3D graphics acceleration to meet the demanding needs of business applications such as real-time stock quotes (Versus), live video feeds (Reuters & Bloombergs), multiple windows applications, word processing, spreadsheets and CAD."
["products_url"]=>
string(45) "www.matrox.com/mga/products/g200_mms/home.cfm"
["products_viewed"]=>
string(1) "1"
["categories_id"]=>
string(1) "4"
["categories_name"]=>
string(14) "Graphics Cards"
["categories_description"]=>
string(0) ""
["languages_name"]=>
string(7) "English"
["languages_code"]=>
string(2) "en"
["manufacturers_name"]=>
string(6) "Matrox"
["manufacturers_image"]=>
string(37) "manufacturers/manufacturer_matrox.gif"
["date_added"]=>
string(19) "2003-12-23 03:18:19"
["last_modified"]=>
NULL
}
["is_cached"]=>
bool(false)
["result"]=>
array(0) {
}
["result_random"]=>
NULL
["limit"]=>
NULL
["resource"]=>
object(mysqli_result)#52 (5) {
["current_field"]=>
int(0)
["field_count"]=>
int(53)
["lengths"]=>
array(53) {
[0]=>
int(1)
[1]=>
int(1)
[2]=>
int(2)
[3]=>
int(8)
[4]=>
int(19)
[5]=>
int(8)
[6]=>
int(1)
[7]=>
int(19)
[8]=>
int(19)
[9]=>
int(0)
[10]=>
int(2)
[11]=>
int(1)
[12]=>
int(1)
[13]=>
int(1)
[14]=>
int(1)
[15]=>
int(1)
[16]=>
int(1)
[17]=>
int(1)
[18]=>
int(1)
[19]=>
int(1)
[20]=>
int(1)
[21]=>
int(1)
[22]=>
int(1)
[23]=>
int(1)
[24]=>
int(1)
[25]=>
int(1)
[26]=>
int(1)
[27]=>
int(8)
[28]=>
int(1)
[29]=>
int(1)
[30]=>
int(1)
[31]=>
int(1)
[32]=>
int(1)
[33]=>
int(1)
[34]=>
int(1)
[35]=>
int(1)
[36]=>
int(1)
[37]=>
int(15)
[38]=>
int(1159)
[39]=>
int(45)
[40]=>
int(1)
[41]=>
int(1)
[42]=>
int(1)
[43]=>
int(14)
[44]=>
int(0)
[45]=>
int(7)
[46]=>
int(2)
[47]=>
int(1)
[48]=>
int(1)
[49]=>
int(6)
[50]=>
int(37)
[51]=>
int(19)
[52]=>
int(0)
}
["num_rows"]=>
int(2)
["type"]=>
int(0)
}
["link"]=>
object(mysqli)#9 (19) {
["affected_rows"]=>
int(2)
["client_info"]=>
string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $"
["client_version"]=>
int(50011)
["connect_errno"]=>
int(0)
["connect_error"]=>
NULL
["errno"]=>
int(0)
["error"]=>
string(0) ""
["error_list"]=>
array(0) {
}
["field_count"]=>
int(11)
["host_info"]=>
string(25) "Localhost via UNIX socket"
["info"]=>
NULL
["insert_id"]=>
int(0)
["server_info"]=>
string(6) "5.6.35"
["server_version"]=>
int(50635)
["stat"]=>
string(137) "Uptime: 48210 Threads: 6 Questions: 20698 Slow queries: 0 Opens: 114 Flush tables: 1 Open tables: 64 Queries per second avg: 0.429"
["sqlstate"]=>
string(5) "00000"
["protocol_version"]=>
int(10)
["thread_id"]=>
int(398)
["warning_count"]=>
int(0)
}
["sql_query"]=>
string(693) "SELECT p.*, pd.*, cd.*, l.name as languages_name, l.code as languages_code,pc.categories_id, m.* from products p LEFT JOIN products_description pd ON p.products_id = pd.products_id LEFT JOIN products_to_categories pc ON p.products_id=pc.products_id LEFT JOIN categories_description cd ON pc.categories_id=cd.categories_id AND cd.language_id = pd.language_id LEFT JOIN manufacturers m ON p.manufacturers_id=m.manufacturers_id LEFT JOIN languages l on pd.language_id=l.languages_id WHERE 1 AND pd.language_id IN (1) AND p.products_price > 0 AND pc.categories_id IN (1,4) AND (p.manufacturers_id IN (0,1,2,3,4,5,6,7,8,9) OR p.manufacturers_id IS NULL) ORDER BY p.products_id ASC "
}