[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&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&r2=1.244">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.244&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&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&r2=1.244">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/catalog/catalog/includes/functions/general.php?rev=1.244&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 > 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->query('select products_quantity from :table_products where products_id = :products_id');
+ $Qstock->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qstock->bindInt(':products_id', $products_id);
+ $Qstock->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->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' => $countries_values['countries_name'],
- 'countries_iso_code_2' => $countries_values['countries_iso_code_2'],
- 'countries_iso_code_3' => $countries_values['countries_iso_code_3']);
</pre><pre class="diff" id="added">+ $Qcountries = $osC_Database->query('select countries_name, countries_iso_code_2, countries_iso_code_3 from :table_countries where countries_id = :countries_id');
+ $Qcountries->bindTable(':table_countries', TABLE_COUNTRIES);
+ $Qcountries->bindInt(':countries_id', $countries_id);
+ $Qcountries->execute();
+
+ $countries_array = $Qcountries->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' => $countries_values['countries_name']);
</pre><pre class="diff" id="added">+ $Qcountries = $osC_Database->query('select countries_name from :table_countries where countries_id = :countries_id');
+ $Qcountries->bindTable(':table_countries', TABLE_COUNTRIES);
+ $Qcountries->bindInt(':countries_id', $countries_id);
+ $Qcountries->execute();
+
+ $countries_array = $Qcountries->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' => $countries_values['countries_id'],
- 'countries_name' => $countries_values['countries_name']);
</pre><pre class="diff" id="added">+ $Qcountries = $osC_Database->query('select countries_id, countries_name from :table_countries order by countries_name');
+ $Qcountries->bindTable(':table_countries', TABLE_COUNTRIES);
+ $Qcountries->execute();
+
+ while ($Qcountries->next()) {
+ $countries_array[] = $Qcountries->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->query('select parent_id from :table_categories where categories_id = :categories_id');
+ $Qlast_category->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qlast_category->bindInt(':categories_id', $cPath_array[($cp_size-1)]);
+ $Qlast_category->execute();
+
+ $Qcurrent_category = $osC_Database->query('select parent_id from :table_categories where categories_id = :categories_id');
+ $Qcurrent_category->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcurrent_category->bindInt(':categories_id', $current_category_id);
+ $Qcurrent_category->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->valueInt('parent_id') == $Qcurrent_category->valueInt('parent_id')) {
</pre><pre class="diff" id="context"> for ($i=0; $i<($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->query('select zone_name from :table_zones where zone_country_id = :zone_country_id and zone_id = :zone_id');
+ $Qzone->bindTable(':table_zones', TABLE_ZONES);
+ $Qzone->bindInt(':zone_country_id', $country_id);
+ $Qzone->bindInt(':zone_id', $zone_id);
+ $Qzone->execute();
+
+ if ($Qzone->numberOfRows()) {
+ return $Qzone->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->query('select zone_code from :table_zones where zone_country_id = :zone_country_id and zone_id = :zone_id');
+ $Qzone->bindTable(':table_zones', TABLE_ZONES);
+ $Qzone->bindInt(':zone_country_id', $country_id);
+ $Qzone->bindInt(':zone_id', $zone_id);
+ $Qzone->execute();
+
+ if ($Qzone->numberOfRows()) {
+ return $Qzone->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->query('select address_format_id from :table_countries where countries_id = :countries_id');
+ $Qaddress_format->bindTable(':table_countries', TABLE_COUNTRIES);
+ $Qaddress_format->bindInt(':countries_id', $country_id);
+ $Qaddress_format->execute();
+
+ if ($Qaddress_format->numberOfRows()) {
+ return $Qaddress_format->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->query('select address_format from :table_address_format where address_format_id = :address_format_id');
+ $Qaddress_format->bindTable(':table_address_format', TABLE_ADDRESS_FORMAT);
+ $Qaddress_format->bindInt(':address_format_id', $address_format_id);
+ $Qaddress_format->execute();
</pre><pre class="diff" id="context">
$company = tep_output_string_protected($address['company']);
if (isset($address['firstname']) && 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->value('address_format');
</pre><pre class="diff" id="context"> eval("\$address = \"$fmt\";");
if ( (ACCOUNT_COMPANY == 'true') && (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->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->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+ $Qaddress->bindInt(':customers_id', $customers_id);
+ $Qaddress->bindInt(':address_book_id', $address_id);
+ $Qaddress->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->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->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->value('languages_id') . "' order by sort_order, cd.categories_name");
- while ($categories = tep_db_fetch_array($categories_query)) {
- $categories_array[] = array('id' => $categories['categories_id'],
- 'text' => $indent . $categories['categories_name']);
</pre><pre class="diff" id="added">+ $Qcategories = $osC_Database->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->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcategories->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcategories->bindInt(':parent_id', $parent_id);
+ $Qcategories->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qcategories->execute();
+
+ while ($Qcategories->next()) {
+ $categories_array[] = array('id' => $Qcategories->valueInt('categories_id'),
+ 'text' => $indent . $Qcategories->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 . '&nbsp;&nbsp;');
</pre><pre class="diff" id="added">+ if ($Qcategories->valueInt('categories_id') != $parent_id) {
+ $categories_array = tep_get_categories($categories_array, $Qcategories->valueInt('categories_id'), $indent . '&nbsp;&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' => $manufacturers['manufacturers_id'], 'text' => $manufacturers['manufacturers_name']);
</pre><pre class="diff" id="added">+ $Qmanufacturers = $osC_Database->query('select manufacturers_id, manufacturers_name from :table_manufacturers order by manufacturers_name');
+ $Qmanufacturers->bindTable(':table_manufacturers', TABLE_MANUFACTURERS);
+ $Qmanufacturers->execute();
+
+ while ($Qmanufacturers->next()) {
+ $manufacturers_array[] = array('id' => $Qmanufacturers->valueInt('manufacturers_id'), 'text' => $Qmanufacturers->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(&$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->query('select categories_id from :table_categories where parent_id = :parent_id');
+ $Qsubcategories->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qsubcategories->bindInt(':parent_id', $parent_id);
+ $Qsubcategories->execute();
+
+ while ($Qsubcategories->next()) {
+ $subcategories_array[sizeof($subcategories_array)] = $Qsubcategories->valueInt('categories_id');
+
+ if ($Qsubcategories->valueInt('categories_id') != $parent_id) {
+ tep_get_subcategories($subcategories_array, $Qsubcategories->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(&$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->query('select parent_id from :table_categories where categories_id = :categories_id');
+ $Qparent->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qparent->bindInt(':categories_id', $categories_id);
+ $Qparent->execute();
+
+ while ($Qparent->next()) {
+ if ($Qparent->valueInt('parent_id') == 0) return true;
+
+ $categories[sizeof($categories)] = $Qparent->valueInt('parent_id');
+
+ if ($Qparent->valueInt('parent_id') != $categories_id) {
+ tep_get_parent_categories($categories, $Qparent->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->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->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcategory->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcategory->bindInt(':products_id', $products_id);
+ $Qcategory->bindInt(':products_status', 1);
+ $Qcategory->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+ if ($Qcategory->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->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->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->query('select count(*) as count from :table_products_attributes where products_id = :products_id');
+ $Qattributes->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+ $Qattributes->bindInt(':products_id', $products_id);
+ $Qattributes->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if ($attributes['count'] > 0) {
</pre><pre class="diff" id="added">+ if ($Qattributes->valueInt('count') > 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->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->query('select count(*) as total from :table_orders where customers_id = :customers_id');
+ $Qorders->bindTable(':table_orders', TABLE_ORDERS);
+ $Qorders->bindInt(':customers_id', $id);
+ $Qorders->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->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->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->query('select count(*) as total from :table_address_book where customers_id = :customers_id');
+ $Qaddresses->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
+ $Qaddresses->bindInt(':customers_id', $id);
+ $Qaddresses->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $addresses['total'];
</pre><pre class="diff" id="added">+ return $Qaddresses->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 -> 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