[TEP-COMMIT] [CVS catalog] use the new database class

hpdl-OfajU3CKLf1/[email protected] 25 Feb 2005 01:56:55 -0000
Newsgroups gmane.comp.web.oscommerce.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>catalog/catalog/includes/functions</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">general.php</a></tt></td><td align="right" id="added">+164</td><td align="right" id="removed">-93</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.243&amp;content-type=text/vnd.viewcvs-markup">1.243</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php.diff?r1=1.243&amp;r2=1.244">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.244&amp;content-type=text/vnd.viewcvs-markup">1.244</a></td></tr>
</table>
<pre class="comment">
use the new database class
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog">catalog</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions">functions</a><br /></span>
<div class="fileheader"><big><b>general.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.243&amp;content-type=text/vnd.viewcvs-markup">1.243</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php.diff?r1=1.243&amp;r2=1.244">-&gt;</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.244&amp;content-type=text/vnd.viewcvs-markup">1.244</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.243 -r1.244
--- general.php	2004/11/24 15:51:39	1.243
+++ general.php	2005/02/25 01:56:52	1.244
@@ -5,7 +5,7 @@
</small></pre><pre class="diff" id="context">   osCommerce, Open Source E-Commerce Solutions
   http://www.oscommerce.com
 
</pre><pre class="diff" id="removed">-  Copyright (c) 200<span id="removedchars">4</span> osCommerce
</pre><pre class="diff" id="added">+  Copyright (c) 200<span id="addedchars">5</span> osCommerce
</pre><pre class="diff" id="context"> 
   Released under the GNU General Public License
 */
</pre><pre class="diff"><small id="info">@@ -57,21 +57,6 @@
</small></pre><pre class="diff" id="context">   }
 
 ////
</pre><pre class="diff" id="removed">-// Return a random row from a database query
-  function tep_random_select($query) {
-    $random_product = '';
-    $random_query = tep_db_query($query);
-    $num_rows = tep_db_num_rows($random_query);
-    if ($num_rows &gt; 0) {
-      $random_row = tep_rand(0, ($num_rows - 1));
-      tep_db_data_seek($random_query, $random_row);
-      $random_product = tep_db_fetch_array($random_query);
-    }
-
-    return $random_product;
-  }
-
-////
</pre><pre class="diff" id="context"> // Return a product's name
 // TABLES: products
   function tep_get_products_name($product_id, $language_id = '') {
</pre><pre class="diff"><small id="info">@@ -98,11 +83,16 @@
</small></pre><pre class="diff" id="context"> // Return a product's stock
 // TABLES: products
   function tep_get_products_stock($products_id) {
</pre><pre class="diff" id="added">+    global $osC_Database;
+
</pre><pre class="diff" id="context">     $products_id = tep_get_prid($products_id);
</pre><pre class="diff" id="removed">-    $stock_query = tep_db_query("select products_quantity from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
-    $stock_values = tep_db_fetch_array($stock_query);
</pre><pre class="diff" id="added">+
+    $Qstock = $osC_Database-&gt;query('select products_quantity from :table_products where products_id = :products_id');
+    $Qstock-&gt;bindTable(':table_products', TABLE_PRODUCTS);
+    $Qstock-&gt;bindInt(':products_id', $products_id);
+    $Qstock-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    return $stock_values['products_quantity'];
</pre><pre class="diff" id="added">+    return $Qstock-&gt;valueInt('products_quantity');
</pre><pre class="diff" id="context">   }
 
 ////
</pre><pre class="diff"><small id="info">@@ -169,24 +159,33 @@
</small></pre><pre class="diff" id="context"> // Returns an array with countries
 // TABLES: countries
   function tep_get_countries($countries_id = '', $with_iso_codes = false) {
</pre><pre class="diff" id="added">+    global $osC_Database;
+
</pre><pre class="diff" id="context">     $countries_array = array();
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">     if (tep_not_null($countries_id)) {
       if ($with_iso_codes == true) {
</pre><pre class="diff" id="removed">-        $countries = tep_db_query("select countries_name, countries_iso_code_2, countries_iso_code_3 from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "' order by countries_name");
-        $countries_values = tep_db_fetch_array($countries);
-        $countries_array = array('countries_name' =&gt; $countries_values['countries_name'],
-                                 'countries_iso_code_2' =&gt; $countries_values['countries_iso_code_2'],
-                                 'countries_iso_code_3' =&gt; $countries_values['countries_iso_code_3']);
</pre><pre class="diff" id="added">+        $Qcountries = $osC_Database-&gt;query('select countries_name, countries_iso_code_2, countries_iso_code_3 from :table_countries where countries_id = :countries_id');
+        $Qcountries-&gt;bindTable(':table_countries', TABLE_COUNTRIES);
+        $Qcountries-&gt;bindInt(':countries_id', $countries_id);
+        $Qcountries-&gt;execute();
+
+        $countries_array = $Qcountries-&gt;toArray();
</pre><pre class="diff" id="context">       } else {
</pre><pre class="diff" id="removed">-        $countries = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$countries_id . "'");
-        $countries_values = tep_db_fetch_array($countries);
-        $countries_array = array('countries_name' =&gt; $countries_values['countries_name']);
</pre><pre class="diff" id="added">+        $Qcountries = $osC_Database-&gt;query('select countries_name from :table_countries where countries_id = :countries_id');
+        $Qcountries-&gt;bindTable(':table_countries', TABLE_COUNTRIES);
+        $Qcountries-&gt;bindInt(':countries_id', $countries_id);
+        $Qcountries-&gt;execute();
+
+        $countries_array = $Qcountries-&gt;toArray();
</pre><pre class="diff" id="context">       }
     } else {
</pre><pre class="diff" id="removed">-      $countries = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");
-      while ($countries_values = tep_db_fetch_array($countries)) {
-        $countries_array[] = array('countries_id' =&gt; $countries_values['countries_id'],
-                                   'countries_name' =&gt; $countries_values['countries_name']);
</pre><pre class="diff" id="added">+      $Qcountries = $osC_Database-&gt;query('select countries_id, countries_name from :table_countries order by countries_name');
+      $Qcountries-&gt;bindTable(':table_countries', TABLE_COUNTRIES);
+      $Qcountries-&gt;execute();
+
+      while ($Qcountries-&gt;next()) {
+        $countries_array[] = $Qcountries-&gt;toArray();
</pre><pre class="diff" id="context">       }
     }
 
</pre><pre class="diff"><small id="info">@@ -202,21 +201,27 @@
</small></pre><pre class="diff" id="context"> ////
 // Generate a path to categories
   function tep_get_path($current_category_id = '') {
</pre><pre class="diff" id="removed">-    global $cPath_array;
</pre><pre class="diff" id="added">+    global $osC_Database, $cPath_array;
</pre><pre class="diff" id="context"> 
     if (tep_not_null($current_category_id)) {
       $cp_size = sizeof($cPath_array);
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context">       if ($cp_size == 0) {
         $cPath_new = $current_category_id;
       } else {
         $cPath_new = '';
</pre><pre class="diff" id="removed">-        $last_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$cPath_array[($cp_size-1)] . "'");
-        $last_category = tep_db_fetch_array($last_category_query);
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        $current_category_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'");
-        $current_category = tep_db_fetch_array($current_category_query);
</pre><pre class="diff" id="added">+        $Qlast_category = $osC_Database-&gt;query('select parent_id from :table_categories where categories_id = :categories_id');
+        $Qlast_category-&gt;bindTable(':table_categories', TABLE_CATEGORIES);
+        $Qlast_category-&gt;bindInt(':categories_id', $cPath_array[($cp_size-1)]);
+        $Qlast_category-&gt;execute();
+
+        $Qcurrent_category = $osC_Database-&gt;query('select parent_id from :table_categories where categories_id = :categories_id');
+        $Qcurrent_category-&gt;bindTable(':table_categories', TABLE_CATEGORIES);
+        $Qcurrent_category-&gt;bindInt(':categories_id', $current_category_id);
+        $Qcurrent_category-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-        if ($last_category['parent_id'] == $current_category['parent_id']) {
</pre><pre class="diff" id="added">+        if ($Qlast_category-&gt;valueInt('parent_id') == $Qcurrent_category-&gt;valueInt('parent_id')) {
</pre><pre class="diff" id="context">           for ($i=0; $i&lt;($cp_size-1); $i++) {
             $cPath_new .= '_' . $cPath_array[$i];
           }
</pre><pre class="diff"><small id="info">@@ -260,10 +265,16 @@
</small></pre><pre class="diff" id="context"> // Returns the zone (State/Province) name
 // TABLES: zones
   function tep_get_zone_name($country_id, $zone_id, $default_zone) {
</pre><pre class="diff" id="removed">-    $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
-    if (tep_db_num_rows($zone_query)) {
-      $zone = tep_db_fetch_array($zone_query);
-      return $zone['zone_name'];
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qzone = $osC_Database-&gt;query('select zone_name from :table_zones where zone_country_id = :zone_country_id and zone_id = :zone_id');
+    $Qzone-&gt;bindTable(':table_zones', TABLE_ZONES);
+    $Qzone-&gt;bindInt(':zone_country_id', $country_id);
+    $Qzone-&gt;bindInt(':zone_id', $zone_id);
+    $Qzone-&gt;execute();
+
+    if ($Qzone-&gt;numberOfRows()) {
+      return $Qzone-&gt;value('zone_name');
</pre><pre class="diff" id="context">     } else {
       return $default_zone;
     }
</pre><pre class="diff"><small id="info">@@ -273,10 +284,16 @@
</small></pre><pre class="diff" id="context"> // Returns the zone (State/Province) code
 // TABLES: zones
   function tep_get_zone_code($country_id, $zone_id, $default_zone) {
</pre><pre class="diff" id="removed">-    $zone_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' and zone_id = '" . (int)$zone_id . "'");
-    if (tep_db_num_rows($zone_query)) {
-      $zone = tep_db_fetch_array($zone_query);
-      return $zone['zone_code'];
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qzone = $osC_Database-&gt;query('select zone_code from :table_zones where zone_country_id = :zone_country_id and zone_id = :zone_id');
+    $Qzone-&gt;bindTable(':table_zones', TABLE_ZONES);
+    $Qzone-&gt;bindInt(':zone_country_id', $country_id);
+    $Qzone-&gt;bindInt(':zone_id', $zone_id);
+    $Qzone-&gt;execute();
+
+    if ($Qzone-&gt;numberOfRows()) {
+      return $Qzone-&gt;value('zone_code');
</pre><pre class="diff" id="context">     } else {
       return $default_zone;
     }
</pre><pre class="diff"><small id="info">@@ -327,10 +344,15 @@
</small></pre><pre class="diff" id="context"> // Returns the address_format_id for the given country
 // TABLES: countries;
   function tep_get_address_format_id($country_id) {
</pre><pre class="diff" id="removed">-    $address_format_query = tep_db_query("select address_format_id as format_id from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");
-    if (tep_db_num_rows($address_format_query)) {
-      $address_format = tep_db_fetch_array($address_format_query);
-      return $address_format['format_id'];
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qaddress_format = $osC_Database-&gt;query('select address_format_id from :table_countries where countries_id = :countries_id');
+    $Qaddress_format-&gt;bindTable(':table_countries', TABLE_COUNTRIES);
+    $Qaddress_format-&gt;bindInt(':countries_id', $country_id);
+    $Qaddress_format-&gt;execute();
+
+    if ($Qaddress_format-&gt;numberOfRows()) {
+      return $Qaddress_format-&gt;valueInt('address_format_id');
</pre><pre class="diff" id="context">     } else {
       return '1';
     }
</pre><pre class="diff"><small id="info">@@ -340,8 +362,12 @@
</small></pre><pre class="diff" id="context"> // Return a formatted address
 // TABLES: address_format
   function tep_address_format($address_format_id, $address, $html, $boln, $eoln) {
</pre><pre class="diff" id="removed">-    $address_format_query = tep_db_query("select address_format as format from " . TABLE_ADDRESS_FORMAT . " where address_format_id = '" . (int)$address_format_id . "'");
-    $address_format = tep_db_fetch_array($address_format_query);
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qaddress_format = $osC_Database-&gt;query('select address_format from :table_address_format where address_format_id = :address_format_id');
+    $Qaddress_format-&gt;bindTable(':table_address_format', TABLE_ADDRESS_FORMAT);
+    $Qaddress_format-&gt;bindInt(':address_format_id', $address_format_id);
+    $Qaddress_format-&gt;execute();
</pre><pre class="diff" id="context"> 
     $company = tep_output_string_protected($address['company']);
     if (isset($address['firstname']) &amp;&amp; tep_not_null($address['firstname'])) {
</pre><pre class="diff"><small id="info">@@ -398,7 +424,7 @@
</small></pre><pre class="diff" id="context">     if ($country == '') $country = tep_output_string_protected($address['country']);
     if ($state != '') $statecomma = $state . ', ';
 
</pre><pre class="diff" id="removed">-    $fmt = $address_format['format'];
</pre><pre class="diff" id="added">+    $fmt = $Qaddress_format-&gt;value('address_format');
</pre><pre class="diff" id="context">     eval("\$address = \"$fmt\";");
 
     if ( (ACCOUNT_COMPANY == 'true') &amp;&amp; (tep_not_null($company)) ) {
</pre><pre class="diff"><small id="info">@@ -412,12 +438,17 @@
</small></pre><pre class="diff" id="context"> // Return a formatted address
 // TABLES: customers, address_book
   function tep_address_label($customers_id, $address_id = 1, $html = false, $boln = '', $eoln = "\n") {
</pre><pre class="diff" id="removed">-    $address_query = tep_db_query("select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customers_id . "' and address_book_id = '" . (int)$address_id . "'");
-    $address = tep_db_fetch_array($address_query);
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qaddress = $osC_Database-&gt;query('select entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from :table_address_book where customers_id = :customers_id and address_book_id = :address_book_id');
+    $Qaddress-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+    $Qaddress-&gt;bindInt(':customers_id', $customers_id);
+    $Qaddress-&gt;bindInt(':address_book_id', $address_id);
+    $Qaddress-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    $format_id = tep_get_address_format_id($address['country_id']);
</pre><pre class="diff" id="added">+    $format_id = tep_get_address_format_id($Qaddress-&gt;valueInt('country_id'));
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    return tep_address_format($format_id, $<span id="removedchars">address</span>, $html, $boln, $eoln);
</pre><pre class="diff" id="added">+    return tep_address_format($format_id, $<span id="addedchars">Qaddress-&gt;toArray()</span>, $html, $boln, $eoln);
</pre><pre class="diff" id="context">   }
 
   function tep_row_number_format($number) {
</pre><pre class="diff"><small id="info">@@ -427,17 +458,23 @@
</small></pre><pre class="diff" id="context">   }
 
   function tep_get_categories($categories_array = '', $parent_id = '0', $indent = '') {
</pre><pre class="diff" id="removed">-    global $osC_Session;
</pre><pre class="diff" id="added">+    global $osC_Database, $osC_Session;
</pre><pre class="diff" id="context"> 
     if (!is_array($categories_array)) $categories_array = array();
 
</pre><pre class="diff" id="removed">-    $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where parent_id = '" . (int)$parent_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$osC_Session-&gt;value('languages_id') . "' order by sort_order, cd.categories_name");
-    while ($categories = tep_db_fetch_array($categories_query)) {
-      $categories_array[] = array('id' =&gt; $categories['categories_id'],
-                                  'text' =&gt; $indent . $categories['categories_name']);
</pre><pre class="diff" id="added">+    $Qcategories = $osC_Database-&gt;query('select c.categories_id, cd.categories_name from :table_categories c, :table_categories_description cd where parent_id = :parent_id and c.categories_id = cd.categories_id and cd.language_id = :language_id order by sort_order, cd.categories_name');
+    $Qcategories-&gt;bindTable(':table_categories', TABLE_CATEGORIES);
+    $Qcategories-&gt;bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+    $Qcategories-&gt;bindInt(':parent_id', $parent_id);
+    $Qcategories-&gt;bindInt(':language_id', $osC_Session-&gt;value('languages_id'));
+    $Qcategories-&gt;execute();
+
+    while ($Qcategories-&gt;next()) {
+      $categories_array[] = array('id' =&gt; $Qcategories-&gt;valueInt('categories_id'),
+                                  'text' =&gt; $indent . $Qcategories-&gt;value('categories_name'));
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-      if ($categories['categories_id'] != $parent_id) {
-        $categories_array = tep_get_categories($categories_array, $categories['categories_id'], $indent . '&amp;nbsp;&amp;nbsp;');
</pre><pre class="diff" id="added">+      if ($Qcategories-&gt;valueInt('categories_id') != $parent_id) {
+        $categories_array = tep_get_categories($categories_array, $Qcategories-&gt;valueInt('categories_id'), $indent . '&amp;nbsp;&amp;nbsp;');
</pre><pre class="diff" id="context">       }
     }
 
</pre><pre class="diff"><small id="info">@@ -445,11 +482,16 @@
</small></pre><pre class="diff" id="context">   }
 
   function tep_get_manufacturers($manufacturers_array = '') {
</pre><pre class="diff" id="added">+    global $osC_Database;
+
</pre><pre class="diff" id="context">     if (!is_array($manufacturers_array)) $manufacturers_array = array();
 
</pre><pre class="diff" id="removed">-    $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from " . TABLE_MANUFACTURERS . " order by manufacturers_name");
-    while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
-      $manufacturers_array[] = array('id' =&gt; $manufacturers['manufacturers_id'], 'text' =&gt; $manufacturers['manufacturers_name']);
</pre><pre class="diff" id="added">+    $Qmanufacturers = $osC_Database-&gt;query('select manufacturers_id, manufacturers_name from :table_manufacturers order by manufacturers_name');
+    $Qmanufacturers-&gt;bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
+    $Qmanufacturers-&gt;execute();
+
+    while ($Qmanufacturers-&gt;next()) {
+      $manufacturers_array[] = array('id' =&gt; $Qmanufacturers-&gt;valueInt('manufacturers_id'), 'text' =&gt; $Qmanufacturers-&gt;value('manufacturers_name'));
</pre><pre class="diff" id="context">     }
 
     return $manufacturers_array;
</pre><pre class="diff"><small id="info">@@ -459,11 +501,18 @@
</small></pre><pre class="diff" id="context"> // Return all subcategory IDs
 // TABLES: categories
   function tep_get_subcategories(&amp;$subcategories_array, $parent_id = 0) {
</pre><pre class="diff" id="removed">-    $subcategories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$parent_id . "'");
-    while ($subcategories = tep_db_fetch_array($subcategories_query)) {
-      $subcategories_array[sizeof($subcategories_array)] = $subcategories['categories_id'];
-      if ($subcategories['categories_id'] != $parent_id) {
-        tep_get_subcategories($subcategories_array, $subcategories['categories_id']);
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qsubcategories = $osC_Database-&gt;query('select categories_id from :table_categories where parent_id = :parent_id');
+    $Qsubcategories-&gt;bindTable(':table_categories', TABLE_CATEGORIES);
+    $Qsubcategories-&gt;bindInt(':parent_id', $parent_id);
+    $Qsubcategories-&gt;execute();
+
+    while ($Qsubcategories-&gt;next()) {
+      $subcategories_array[sizeof($subcategories_array)] = $Qsubcategories-&gt;valueInt('categories_id');
+
+      if ($Qsubcategories-&gt;valueInt('categories_id') != $parent_id) {
+        tep_get_subcategories($subcategories_array, $Qsubcategories-&gt;valueInt('categories_id'));
</pre><pre class="diff" id="context">       }
     }
   }
</pre><pre class="diff"><small id="info">@@ -794,12 +843,20 @@
</small></pre><pre class="diff" id="context"> // Recursively go through the categories and retreive all parent categories IDs
 // TABLES: categories
   function tep_get_parent_categories(&amp;$categories, $categories_id) {
</pre><pre class="diff" id="removed">-    $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$categories_id . "'");
-    while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
-      if ($parent_categories['parent_id'] == 0) return true;
-      $categories[sizeof($categories)] = $parent_categories['parent_id'];
-      if ($parent_categories['parent_id'] != $categories_id) {
-        tep_get_parent_categories($categories, $parent_categories['parent_id']);
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qparent = $osC_Database-&gt;query('select parent_id from :table_categories where categories_id = :categories_id');
+    $Qparent-&gt;bindTable(':table_categories', TABLE_CATEGORIES);
+    $Qparent-&gt;bindInt(':categories_id', $categories_id);
+    $Qparent-&gt;execute();
+
+    while ($Qparent-&gt;next()) {
+      if ($Qparent-&gt;valueInt('parent_id') == 0) return true;
+
+      $categories[sizeof($categories)] = $Qparent-&gt;valueInt('parent_id');
+
+      if ($Qparent-&gt;valueInt('parent_id') != $categories_id) {
+        tep_get_parent_categories($categories, $Qparent-&gt;valueInt('parent_id'));
</pre><pre class="diff" id="context">       }
     }
   }
</pre><pre class="diff"><small id="info">@@ -808,21 +865,27 @@
</small></pre><pre class="diff" id="context"> // Construct a category path to the product
 // TABLES: products_to_categories
   function tep_get_product_path($products_id) {
</pre><pre class="diff" id="added">+    global $osC_Database;
+
</pre><pre class="diff" id="context">     $cPath = '';
 
</pre><pre class="diff" id="removed">-    $category_query = tep_db_query("select p2c.categories_id from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = '" . (int)$products_id . "' and p.products_status = '1' and p.products_id = p2c.products_id limit 1");
-    if (tep_db_num_rows($category_query)) {
-      $category = tep_db_fetch_array($category_query);
</pre><pre class="diff" id="added">+    $Qcategory = $osC_Database-&gt;query('select p2c.categories_id from :table_products p, :table_products_to_categories p2c where p.products_id = :products_id and p.products_status = :products_status and p.products_id = p2c.products_id limit 1');
+    $Qcategory-&gt;bindTable(':table_products', TABLE_PRODUCTS);
+    $Qcategory-&gt;bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+    $Qcategory-&gt;bindInt(':products_id', $products_id);
+    $Qcategory-&gt;bindInt(':products_status', 1);
+    $Qcategory-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+    if ($Qcategory-&gt;numberOfRows()) {
</pre><pre class="diff" id="context">       $categories = array();
</pre><pre class="diff" id="removed">-      tep_get_parent_categories($categories, $category['categories_id']);
</pre><pre class="diff" id="added">+      tep_get_parent_categories($categories, $Qcategory-&gt;valueInt('categories_id'));
</pre><pre class="diff" id="context"> 
       $categories = array_reverse($categories);
 
       $cPath = implode('_', $categories);
 
       if (tep_not_null($cPath)) $cPath .= '_';
</pre><pre class="diff" id="removed">-      $cPath .= $category['categories_id'];
</pre><pre class="diff" id="added">+      $cPath .= $Qcategory-&gt;valueInt('categories_id');
</pre><pre class="diff" id="context">     }
 
     return $cPath;
</pre><pre class="diff"><small id="info">@@ -948,10 +1011,14 @@
</small></pre><pre class="diff" id="context"> ////
 // Check if product has attributes
   function tep_has_product_attributes($products_id) {
</pre><pre class="diff" id="removed">-    $attributes_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "'");
-    $attributes = tep_db_fetch_array($attributes_query);
</pre><pre class="diff" id="added">+    global $osC_Database;
+
+    $Qattributes = $osC_Database-&gt;query('select count(*) as count from :table_products_attributes where products_id = :products_id');
+    $Qattributes-&gt;bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+    $Qattributes-&gt;bindInt(':products_id', $products_id);
+    $Qattributes-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    if ($attributes['count'] &gt; 0) {
</pre><pre class="diff" id="added">+    if ($Qattributes-&gt;valueInt('count') &gt; 0) {
</pre><pre class="diff" id="context">       return true;
     } else {
       return false;
</pre><pre class="diff"><small id="info">@@ -1168,7 +1235,7 @@
</small></pre><pre class="diff" id="context">   }
 
   function tep_count_customer_orders($id = '', $check_session = true) {
</pre><pre class="diff" id="removed">-    global $osC_Customer;
</pre><pre class="diff" id="added">+    global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context"> 
     if (is_numeric($id) == false) {
       if ($osC_Customer-&gt;isLoggedOn()) {
</pre><pre class="diff"><small id="info">@@ -1184,14 +1251,16 @@
</small></pre><pre class="diff" id="context">       }
     }
 
</pre><pre class="diff" id="removed">-    $orders_check_query = tep_db_query("select count(*) as total from " . TABLE_ORDERS . " where customers_id = '" . (int)$id . "'");
-    $orders_check = tep_db_fetch_array($orders_check_query);
</pre><pre class="diff" id="added">+    $Qorders = $osC_Database-&gt;query('select count(*) as total from :table_orders where customers_id = :customers_id');
+    $Qorders-&gt;bindTable(':table_orders', TABLE_ORDERS);
+    $Qorders-&gt;bindInt(':customers_id', $id);
+    $Qorders-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    return $orders_check['total'];
</pre><pre class="diff" id="added">+    return $Qorders-&gt;valueInt('total');
</pre><pre class="diff" id="context">   }
 
   function tep_count_customer_address_book_entries($id = '', $check_session = true) {
</pre><pre class="diff" id="removed">-    global $osC_Customer;
</pre><pre class="diff" id="added">+    global $osC_Database, $osC_Customer;
</pre><pre class="diff" id="context"> 
     if (is_numeric($id) == false) {
       if ($osC_Customer-&gt;isLoggedOn()) {
</pre><pre class="diff"><small id="info">@@ -1207,10 +1276,12 @@
</small></pre><pre class="diff" id="context">       }
     }
 
</pre><pre class="diff" id="removed">-    $addresses_query = tep_db_query("select count(*) as total from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$id . "'");
-    $addresses = tep_db_fetch_array($addresses_query);
</pre><pre class="diff" id="added">+    $Qaddresses = $osC_Database-&gt;query('select count(*) as total from :table_address_book where customers_id = :customers_id');
+    $Qaddresses-&gt;bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+    $Qaddresses-&gt;bindInt(':customers_id', $id);
+    $Qaddresses-&gt;execute();
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="removed">-    return $addresses['total'];
</pre><pre class="diff" id="added">+    return $Qaddresses-&gt;valueInt('total');
</pre><pre class="diff" id="context">   }
 
 // nl2br() prior PHP 4.2.0 did not convert linefeeds on all OSs (it only converted \n)
</pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.9</small></center>
</body></html>


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click