[TEP-COMMIT] [CVS admin] replace calls to the database functions with the database class
hpdl-OfajU3CKLf1/[email protected] 2 Nov 2004 00:59:21 -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>admin/admin/includes</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt><a href="#file1">application_top.php</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php?rev=1.178&content-type=text/vnd.viewcvs-markup">1.178</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php.diff?r1=1.178&r2=1.179">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php?rev=1.179&content-type=text/vnd.viewcvs-markup">1.179</a></td></tr>
<tr class="alt"><td><tt>functions/<a href="#file2">general.php</a></tt></td><td align="right" id="added">+539</td><td align="right" id="removed">-403</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/general.php?rev=1.173&content-type=text/vnd.viewcvs-markup">1.173</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/general.php.diff?r1=1.173&r2=1.174">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/general.php?rev=1.174&content-type=text/vnd.viewcvs-markup">1.174</a></td></tr>
<tr><td><tt> /<a href="#file3">html_output.php</a></tt></td><td align="right" id="added">+25</td><td align="right" id="removed">-9</td><td nowrap="nowrap" align="center"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php?rev=1.33&content-type=text/vnd.viewcvs-markup">1.33</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php.diff?r1=1.33&r2=1.34">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php?rev=1.34&content-type=text/vnd.viewcvs-markup">1.34</a></td></tr>
<tr><td></td><td align="right" id="added">+565</td><td align="right" id="removed">-416</td><td></td></tr>
</table>
<small id="info">3 modified files</small><br />
<pre class="comment">
replace calls to the database functions with the database class
*warning* there is a slight inconsistency with this commit in regard to the
reviews and reviews_description database tables, as these tables have been
merged in our internal CVS server, and some of the changes in this commmit
reflect that change
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes">includes</a><br /></span>
<div class="fileheader"><big><b>application_top.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php?rev=1.178&content-type=text/vnd.viewcvs-markup">1.178</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php.diff?r1=1.178&r2=1.179">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/application_top.php?rev=1.179&content-type=text/vnd.viewcvs-markup">1.179</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.178 -r1.179
--- application_top.php 2004/10/28 19:14:26 1.178
+++ application_top.php 2004/11/02 00:59:11 1.179
@@ -48,10 +48,7 @@
</small></pre><pre class="diff" id="context">
// initialize the cache class
require('../includes/classes/cache.php');
</pre><pre class="diff" id="removed">- $osC_Cache = new osC_Cache;
-
-// include the database functions
- require('../includes/functions/database.php');
</pre><pre class="diff" id="added">+ $osC_Cache = new osC_Cache();
</pre><pre class="diff" id="context">
// include the database class
require('../includes/classes/database.php');
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/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/admin/admin/includes/functions/general.php?rev=1.173&content-type=text/vnd.viewcvs-markup">1.173</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/general.php.diff?r1=1.173&r2=1.174">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/general.php?rev=1.174&content-type=text/vnd.viewcvs-markup">1.174</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.173 -r1.174
--- general.php 2004/10/31 09:57:44 1.173
+++ general.php 2004/11/02 00:59:12 1.174
@@ -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">3</span> osCommerce
</pre><pre class="diff" id="added">+ Copyright (c) 200<span id="addedchars">4</span> osCommerce
</pre><pre class="diff" id="context">
Released under the GNU General Public License
*/
</pre><pre class="diff"><small id="info">@@ -46,13 +46,6 @@
</small></pre><pre class="diff" id="context"> return preg_replace("/[<>]/", '_', $string);
}
</pre><pre class="diff" id="removed">- function tep_customers_name($customers_id) {
- $customers = tep_db_query("select customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " where customers_id = '" . (int)$customers_id . "'");
- $customers_values = tep_db_fetch_array($customers);
-
- return $customers_values['customers_firstname'] . ' ' . $customers_values['customers_lastname'];
- }
-
</pre><pre class="diff" id="context"> function tep_date_long($raw_date) {
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return false;
</pre><pre class="diff"><small id="info">@@ -101,51 +94,6 @@
</small></pre><pre class="diff" id="context"> return strftime(DATE_TIME_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
}
</pre><pre class="diff" id="removed">- function tep_draw_products_pull_down($name, $parameters = '', $exclude = '') {
- global $osC_Session, $osC_Currencies;
-
- if ($exclude == '') {
- $exclude = array();
- }
-
- $select_string = '<select name="' . $name . '"';
-
- if ($parameters) {
- $select_string .= ' ' . $parameters;
- }
-
- $select_string .= '>';
-
- $products_query = tep_db_query("select p.products_id, pd.products_name, p.products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd where p.products_id = pd.products_id and pd.language_id = '" . (int)$osC_Session->value('languages_id') . "' order by products_name");
- while ($products = tep_db_fetch_array($products_query)) {
- if (!in_array($products['products_id'], $exclude)) {
- $select_string .= '<option value="' . $products['products_id'] . '">' . $products['products_name'] . ' (' . $osC_Currencies->format($products['products_price']) . ')</option>';
- }
- }
-
- $select_string .= '</select>';
-
- return $select_string;
- }
-
- function tep_options_name($options_id) {
- global $osC_Session;
-
- $options = tep_db_query("select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$options_id . "' and language_id = '" . (int)$osC_Session->value('languages_id') . "'");
- $options_values = tep_db_fetch_array($options);
-
- return $options_values['products_options_name'];
- }
-
- function tep_values_name($values_id) {
- global $osC_Session;
-
- $values = tep_db_query("select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$values_id . "' and language_id = '" . (int)$osC_Session->value('languages_id') . "'");
- $values_values = tep_db_fetch_array($values);
-
- return $values_values['products_options_values_name'];
- }
-
</pre><pre class="diff" id="context"> function tep_info_image($image, $alt, $width = '', $height = '') {
if (tep_not_null($image) && (file_exists(DIR_FS_CATALOG_IMAGES . $image)) ) {
$image = tep_image(DIR_WS_CATALOG_IMAGES . $image, $alt, $width, $height);
</pre><pre class="diff"><small id="info">@@ -177,24 +125,26 @@
</small></pre><pre class="diff" id="context"> }
function tep_get_country_name($country_id) {
</pre><pre class="diff" id="removed">- $country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$country_id . "'");
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (!tep_db_num_rows($country_query)) {
- return $country_id;
- } else {
- $country = tep_db_fetch_array($country_query);
- return $country['countries_name'];
- }
</pre><pre class="diff" id="added">+ $Qcountry = $osC_Database->query('select countries_name from :table_countries where countries_id = :countries_id');
+ $Qcountry->bindTable(':table_countries', TABLE_COUNTRIES);
+ $Qcountry->bindInt(':countries_id', $country_id);
+ $Qcountry->execute();
+
+ return $Qcountry->value('countries_name');
</pre><pre class="diff" id="context"> }
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'];
- } else {
- return $default_zone;
- }
</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();
+
+ return ($Qzone->numberOfRows() > 0) ? $Qzone->value('zone_name') : $default_zone;
</pre><pre class="diff" id="context"> }
function tep_not_null($value) {
</pre><pre class="diff"><small id="info">@@ -219,26 +169,19 @@
</small></pre><pre class="diff" id="context"> return stristr($HTTP_USER_AGENT, $component);
}
</pre><pre class="diff" id="removed">- function tep_tax_classes_pull_down($parameters, $selected = '') {
- $select_string = '<select ' . $parameters . '>';
- $classes_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
- while ($classes = tep_db_fetch_array($classes_query)) {
- $select_string .= '<option value="' . $classes['tax_class_id'] . '"';
- if ($selected == $classes['tax_class_id']) $select_string .= ' SELECTED';
- $select_string .= '>' . $classes['tax_class_title'] . '</option>';
- }
- $select_string .= '</select>';
-
- return $select_string;
- }
-
</pre><pre class="diff" id="context"> function tep_geo_zones_pull_down($parameters, $selected = '') {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $select_string = '<select ' . $parameters . '>';
</pre><pre class="diff" id="removed">- $zones_query = tep_db_query("select geo_zone_id, geo_zone_name from " . TABLE_GEO_ZONES . " order by geo_zone_name");
- while ($zones = tep_db_fetch_array($zones_query)) {
- $select_string .= '<option value="' . $zones['geo_zone_id'] . '"';
- if ($selected == $zones['geo_zone_id']) $select_string .= ' SELECTED';
- $select_string .= '>' . $zones['geo_zone_name'] . '</option>';
</pre><pre class="diff" id="added">+
+ $Qzones = $osC_Database->query('select geo_zone_id, geo_zone_name from :table_geo_zones order by geo_zone_name');
+ $Qzones->bindTable(':table_geo_zones', TABLE_GEO_ZONES);
+ $Qzones->execute();
+
+ while ($Qzones->next()) {
+ $select_string .= '<option value="' . $Qzones->valueInt('geo_zone_id') . '"';
+ if ($selected == $Qzones->valueInt('geo_zone_id')) $select_string .= ' SELECTED';
+ $select_string .= '>' . $Qzones->value('geo_zone_name') . '</option>';
</pre><pre class="diff" id="context"> }
$select_string .= '</select>';
</pre><pre class="diff"><small id="info">@@ -246,21 +189,23 @@
</small></pre><pre class="diff" id="context"> }
function tep_get_geo_zone_name($geo_zone_id) {
</pre><pre class="diff" id="removed">- $zones_query = tep_db_query("select geo_zone_name from " . TABLE_GEO_ZONES . " where geo_zone_id = '" . (int)$geo_zone_id . "'");
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (!tep_db_num_rows($zones_query)) {
- $geo_zone_name = $geo_zone_id;
- } else {
- $zones = tep_db_fetch_array($zones_query);
- $geo_zone_name = $zones['geo_zone_name'];
- }
</pre><pre class="diff" id="added">+ $Qzone = $osC_Database->query('select geo_zone_name from :table_geo_zones where geo_zone_id = :geo_zone_id');
+ $Qzone->bindTable(':table_geo_zones', TABLE_GEO_ZONES);
+ $Qzone->bindInt('geo_zone_id', $geo_zone_id);
+ $Qzone->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $geo_zone_name;
</pre><pre class="diff" id="added">+ return $Qzone->value('geo_zone_name');
</pre><pre class="diff" id="context"> }
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;
+
+ $Qformat = $osC_Database->query('select address_format from :table_address_format where address_format_id = :address_format_id');
+ $Qformat->bindTable(':table_address_format', TABLE_ADDRESS_FORMAT);
+ $Qformat->bindInt(':address_format_id', $address_format_id);
+ $Qformat->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">@@ -317,7 +262,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 = $Qformat->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">@@ -327,33 +272,6 @@
</small></pre><pre class="diff" id="context"> return $address;
}
</pre><pre class="diff" id="removed">- ////////////////////////////////////////////////////////////////////////////////////////////////
- //
- // Function : tep_get_zone_code
- //
- // Arguments : country country code string
- // zone state/province zone_id
- // def_state default string if zone==0
- //
- // Return : state_prov_code state/province code
- //
- // Description : Function to retrieve the state/province code (as in FL for Florida etc)
- //
- ////////////////////////////////////////////////////////////////////////////////////////////////
- function tep_get_zone_code($country, $zone, $def_state) {
-
- $state_prov_query = tep_db_query("select zone_code from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id = '" . (int)$zone . "'");
-
- if (!tep_db_num_rows($state_prov_query)) {
- $state_prov_code = $def_state;
- }
- else {
- $state_prov_values = tep_db_fetch_array($state_prov_query);
- $state_prov_code = $state_prov_values['zone_code'];
- }
-
- return $state_prov_code;
- }
</pre><pre class="diff" id="context">
function tep_get_uprid($prid, $params) {
$uprid = $prid;
</pre><pre class="diff"><small id="info">@@ -373,100 +291,54 @@
</small></pre><pre class="diff" id="context"> }
function tep_get_languages() {
</pre><pre class="diff" id="removed">- $languages_query = tep_db_query("select languages_id, name, code, image, directory from " . TABLE_LANGUAGES . " order by sort_order");
- while ($languages = tep_db_fetch_array($languages_query)) {
- $languages_array[] = array('id' => $languages['languages_id'],
- 'name' => $languages['name'],
- 'code' => $languages['code'],
- 'image' => $languages['image'],
- 'directory' => $languages['directory']);
- }
-
- return $languages_array;
- }
-
- function tep_get_category_name($category_id, $language_id) {
- $category_query = tep_db_query("select categories_name from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "' and language_id = '" . (int)$language_id . "'");
- $category = tep_db_fetch_array($category_query);
-
- return $category['categories_name'];
- }
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- function tep_get_orders_status_name($orders_status_id, $language_id = '') {
- global $osC_Session;
</pre><pre class="diff" id="added">+ $languages_array = array();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (!$language_id) $language_id = $osC_Session->value('languages_id');
- $orders_status_query = tep_db_query("select orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id = '" . (int)$orders_status_id . "' and language_id = '" . (int)$language_id . "'");
- $orders_status = tep_db_fetch_array($orders_status_query);
</pre><pre class="diff" id="added">+ $Qlanguages = $osC_Database->query('select languages_id, name, code, image, directory from :table_languages order by sort_order, name');
+ $Qlanguages->bindTable(':table_languages', TABLE_LANGUAGES);
+ $Qlanguages->execute();
+
+ while ($Qlanguages->next()) {
+ $languages_array[] = array('id' => $Qlanguages->valueInt('languages_id'),
+ 'name' => $Qlanguages->value('name'),
+ 'code' => $Qlanguages->value('code'),
+ 'image' => $Qlanguages->value('image'),
+ 'directory' => $Qlanguages->value('directory'));
+ }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $orders_status['orders_status_name'];
</pre><pre class="diff" id="added">+ return $languages_array;
</pre><pre class="diff" id="context"> }
function tep_get_weight_class_title($weight_class_id, $language_id = '') {
</pre><pre class="diff" id="removed">- global $osC_Session;
-
- if (!$language_id) $language_id = $osC_Session->value('languages_id');
- $weight_class_query = tep_db_query("select weight_class_title from " . TABLE_WEIGHT_CLASS . " where weight_class_id = '" . (int)$weight_class_id . "' and language_id = '" . (int)$language_id . "'");
- $weight_class = tep_db_fetch_array($weight_class_query);
-
- return $weight_class['weight_class_title'];
- }
-
- function tep_get_weight_class_key($weight_class_id, $language_id = '') {
- global $osC_Session;
</pre><pre class="diff" id="added">+ global $osC_Database, $osC_Session;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (!$language_id) $language_id = $osC_Session->value('languages_id');
- $weight_class_query = tep_db_query("select weight_class_key from " . TABLE_WEIGHT_CLASS . " where weight_class_id = '" . (int)$weight_class_id . "' and language_id = '" . (int)$language_id . "'");
- $weight_class = tep_db_fetch_array($weight_class_query);
-
- return $weight_class['weight_class_key'];
- }
-
- function tep_get_orders_status() {
- global $osC_Session;
-
- $orders_status_array = array();
- $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$osC_Session->value('languages_id') . "' order by orders_status_id");
- while ($orders_status = tep_db_fetch_array($orders_status_query)) {
- $orders_status_array[] = array('id' => $orders_status['orders_status_id'],
- 'text' => $orders_status['orders_status_name']);
</pre><pre class="diff" id="added">+ if (empty($language_id)) {
+ $language_id = $osC_Session->value('languages_id');
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="removed">-
- return $orders_status_array;
- }
-
- function tep_get_products_name($product_id, $language_id = 0) {
- global $osC_Session;
-
- if ($language_id == 0) $language_id = $osC_Session->value('languages_id');
- $product_query = tep_db_query("select products_name from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
- $product = tep_db_fetch_array($product_query);
-
- return $product['products_name'];
- }
-
- function tep_get_products_description($product_id, $language_id) {
- $product_query = tep_db_query("select products_description from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
- $product = tep_db_fetch_array($product_query);
-
- return $product['products_description'];
- }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- function tep_get_products_url($product_id, $language_id) {
- $product_query = tep_db_query("select products_url from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "' and language_id = '" . (int)$language_id . "'");
- $product = tep_db_fetch_array($product_query);
</pre><pre class="diff" id="added">+ $Qweight = $osC_Database->query('select weight_class_title from :table_weight_class where weight_class_id = :weight_class_id and language_id = :language_id');
+ $Qweight->bindTable(':table_weight_class', TABLE_WEIGHT_CLASS);
+ $Qweight->bindInt(':weight_class_id', $weight_class_id);
+ $Qweight->bindInt(':language_id', $language_id);
+ $Qweight->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $product['products_url'];
</pre><pre class="diff" id="added">+ return $Qweight->value('weight_class_title');
</pre><pre class="diff" id="context"> }
////
// Return the manufacturers URL in the needed language
// TABLES: manufacturers_info
function tep_get_manufacturer_url($manufacturer_id, $language_id) {
</pre><pre class="diff" id="removed">- $manufacturer_query = tep_db_query("select manufacturers_url from " . TABLE_MANUFACTURERS_INFO . " where manufacturers_id = '" . (int)$manufacturer_id . "' and languages_id = '" . (int)$language_id . "'");
- $manufacturer = tep_db_fetch_array($manufacturer_query);
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $Qmanufacturer = $osC_Database->query('select manufacturers_url from :table_manufacturers_info where manufacturers_id = :manufacturers_id and languages_id = :languages_id');
+ $Qmanufacturer->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
+ $Qmanufacturer->bindInt(':manufacturers_id', $manufacturer_id);
+ $Qmanufacturer->bindInt(':languages_id', $language_id);
+ $Qmanufacturer->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- return $manufacturer['manufacturers_url'];
</pre><pre class="diff" id="added">+ return $Qmanufacturer->value('manufacturers_url');
</pre><pre class="diff" id="context"> }
////
</pre><pre class="diff"><small id="info">@@ -484,23 +356,30 @@
</small></pre><pre class="diff" id="context"> // Count how many products exist in a category
// TABLES: products, products_to_categories, categories
function tep_products_in_category_count($categories_id, $include_deactivated = false) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $products_count = 0;
</pre><pre class="diff" id="removed">- if ($include_deactivated) {
- $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p2c.categories_id = '" . (int)$categories_id . "'");
- } else {
- $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int)$categories_id . "'");
</pre><pre class="diff" id="added">+ $Qproducts = $osC_Database->query('select count(*) as total from :table_products p, :table_products_to_categories p2c where p.products_id = p2c.products_id and p2c.categories_id = :categories_id');
+
+ if ($include_deactivated === true) {
+ $Qproducts->appendQuery('and p.products_status = 1');
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="removed">- $products = tep_db_fetch_array($products_query);
</pre><pre class="diff" id="added">+ $Qproducts->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qproducts->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qproducts->bindInt(':categories_id', $categories_id);
+ $Qproducts->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $products_count += $products['total'];
</pre><pre class="diff" id="added">+ $products_count += $Qproducts->valueInt('total');
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $childs_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
- if (tep_db_num_rows($childs_query)) {
- while ($childs = tep_db_fetch_array($childs_query)) {
- $products_count += tep_products_in_category_count($childs['categories_id'], $include_deactivated);
- }
</pre><pre class="diff" id="added">+ $Qchildren = $osC_Database->query('select categories_id from :table_categories where parent_id = :parent_id');
+ $Qchildren->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qchildren->bindInt(':parent_id', $categories_id);
+ $Qchildren->execute();
+
+ while ($Qchildren->next()) {
+ $products_count += tep_products_in_category_count($Qchildren->valueInt('categories_id'), $include_deactivated);
</pre><pre class="diff" id="context"> }
return $products_count;
</pre><pre class="diff"><small id="info">@@ -510,12 +389,19 @@
</small></pre><pre class="diff" id="context"> // Count how many subcategories exist in a category
// TABLES: categories
function tep_childs_in_category_count($categories_id) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $categories_count = 0;
</pre><pre class="diff" id="added">+
+ $Qcategories = $osC_Database->query('select categories_id from :table_categories where parent_id = :parent_id');
+ $Qcategories->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcategories->bindInt(':parent_id', $categories_id);
+ $Qcategories->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $categories_query = tep_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int)$categories_id . "'");
- while ($categories = tep_db_fetch_array($categories_query)) {
</pre><pre class="diff" id="added">+ while ($Qcategories->next()) {
</pre><pre class="diff" id="context"> $categories_count++;
</pre><pre class="diff" id="removed">- $categories_count += tep_childs_in_category_count($categories['categories_id']);
</pre><pre class="diff" id="added">+
+ $categories_count += tep_childs_in_category_count($Qcategories->valueInt('categories_id'));
</pre><pre class="diff" id="context"> }
return $categories_count;
</pre><pre class="diff"><small id="info">@@ -525,15 +411,22 @@
</small></pre><pre class="diff" id="context"> // Returns an array with countries
// TABLES: countries
function tep_get_countries($default = '') {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $countries_array = array();
</pre><pre class="diff" id="removed">- if ($default) {
</pre><pre class="diff" id="added">+
+ if (!empty($default)) {
</pre><pre class="diff" id="context"> $countries_array[] = array('id' => '',
'text' => $default);
}
</pre><pre class="diff" id="removed">- $countries_query = tep_db_query("select countries_id, countries_name from " . TABLE_COUNTRIES . " order by countries_name");
- while ($countries = tep_db_fetch_array($countries_query)) {
- $countries_array[] = array('id' => $countries['countries_id'],
- 'text' => $countries['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[] = array('id' => $Qcountries->valueInt('countries_id'),
+ 'text' => $Qcountries->value('countries_name'));
</pre><pre class="diff" id="context"> }
return $countries_array;
</pre><pre class="diff"><small id="info">@@ -542,11 +435,18 @@
</small></pre><pre class="diff" id="context"> ////
// return an array with country zones
function tep_get_country_zones($country_id) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $zones_array = array();
</pre><pre class="diff" id="removed">- $zones_query = tep_db_query("select zone_id, zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country_id . "' order by zone_name");
- while ($zones = tep_db_fetch_array($zones_query)) {
- $zones_array[] = array('id' => $zones['zone_id'],
- 'text' => $zones['zone_name']);
</pre><pre class="diff" id="added">+
+ $Qzones = $osC_Database->query('select zone_id, zone_name from :table_zones where zone_country_id = :zone_country_id order by zone_name');
+ $Qzones->bindTable(':table_zones', TABLE_ZONES);
+ $Qzones->bindInt(':zone_country_id', $country_id);
+ $Qzones->execute();
+
+ while ($Qzones->next()) {
+ $zones_array[] = array('id' => $Qzones->valueInt('zone_id'),
+ 'text' => $Qzones->value('zone_name'));
</pre><pre class="diff" id="context"> }
return $zones_array;
</pre><pre class="diff"><small id="info">@@ -580,11 +480,17 @@
</small></pre><pre class="diff" id="context"> ////
// Get list of address_format_id's
function tep_get_address_formats() {
</pre><pre class="diff" id="removed">- $address_format_query = tep_db_query("select address_format_id from " . TABLE_ADDRESS_FORMAT . " order by address_format_id");
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $address_format_array = array();
</pre><pre class="diff" id="removed">- while ($address_format_values = tep_db_fetch_array($address_format_query)) {
- $address_format_array[] = array('id' => $address_format_values['address_format_id'],
- 'text' => $address_format_values['address_format_id']);
</pre><pre class="diff" id="added">+
+ $Qformats = $osC_Database->query('select address_format_id from :table_address_format order by address_format_id');
+ $Qformats->bindTable(':table_address_format', TABLE_ADDRESS_FORMAT);
+ $Qformats->execute();
+
+ while ($Qformats->next()) {
+ $address_format_array[] = array('id' => $Qformats->valueInt('address_format_id'),
+ 'text' => $Qformats->valueInt('address_format_id'));
</pre><pre class="diff" id="context"> }
return $address_format_array;
}
</pre><pre class="diff"><small id="info">@@ -600,13 +506,19 @@
</small></pre><pre class="diff" id="context"> }
function tep_cfg_pull_down_tax_classes($tax_class_id, $key = '') {
</pre><pre class="diff" id="removed">- $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="added">+ $name = (empty($key)) ? 'configuration_value' : 'configuration[' . $key . ']';
+
</pre><pre class="diff" id="context"> $tax_class_array = array(array('id' => '0', 'text' => TEXT_NONE));
</pre><pre class="diff" id="removed">- $tax_class_query = tep_db_query("select tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
- while ($tax_class = tep_db_fetch_array($tax_class_query)) {
- $tax_class_array[] = array('id' => $tax_class['tax_class_id'],
- 'text' => $tax_class['tax_class_title']);
</pre><pre class="diff" id="added">+
+ $Qclasses = $osC_Database->query('select tax_class_id, tax_class_title from :table_tax_class order by tax_class_title');
+ $Qclasses->bindTable(':table_tax_class', TABLE_TAX_CLASS);
+ $Qclasses->execute();
+
+ while ($Qclasses->next()) {
+ $tax_class_array[] = array('id' => $Qclasses->valueInt('tax_class_id'),
+ 'text' => $Qclasses->value('tax_class_title'));
</pre><pre class="diff" id="context"> }
return tep_draw_pull_down_menu($name, $tax_class_array, $tax_class_id);
</pre><pre class="diff"><small id="info">@@ -619,77 +531,34 @@
</small></pre><pre class="diff" id="context"> }
function tep_cfg_get_zone_name($zone_id) {
</pre><pre class="diff" id="removed">- $zone_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_id = '" . (int)$zone_id . "'");
</pre><pre class="diff" id="added">+ global $osC_Database;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if (!tep_db_num_rows($zone_query)) {
- return $zone_id;
- } else {
- $zone = tep_db_fetch_array($zone_query);
- return $zone['zone_name'];
- }
</pre><pre class="diff" id="added">+ $Qzone = $osC_Database->query('select zone_name from :table_zones where zone_id = :zone_id');
+ $Qzone->bindTable(':table_zones', TABLE_ZONES);
+ $Qzone->bindInt(':zone_id', $zone_id);
+ $Qzone->execute();
+
+ return $Qzone->value('zone_name');
</pre><pre class="diff" id="context"> }
function tep_cfg_pull_down_weight_classes($weight_class_id, $key = '') {
</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">
</pre><pre class="diff" id="removed">- $name = (($key) ? 'configuration[' . $key . ']' : 'configuration_value');
</pre><pre class="diff" id="added">+ $name = (empty($key)) ? 'configuration_value' : 'configuration[' . $key . ']';
</pre><pre class="diff" id="context">
$weight_class_array = array();
</pre><pre class="diff" id="removed">- $weight_class_query = tep_db_query("select weight_class_id, weight_class_title from " . TABLE_WEIGHT_CLASS . " where language_id = '" . (int)$osC_Session->value('languages_id') . "' order by weight_class_title");
- while ($weight_class = tep_db_fetch_array($weight_class_query)) {
- $weight_class_array[] = array('id' => $weight_class['weight_class_id'],
- 'text' => $weight_class['weight_class_title']);
- }
-
- return tep_draw_pull_down_menu($name, $weight_class_array, $weight_class_id);
- }
-
-////
-// Sets the status of a banner
- function tep_set_banner_status($banners_id, $status) {
- if ($status == '1') {
- return tep_db_query("update " . TABLE_BANNERS . " set status = '1', expires_impressions = NULL, expires_date = NULL, date_status_change = NULL where banners_id = '" . $banners_id . "'");
- } elseif ($status == '0') {
- return tep_db_query("update " . TABLE_BANNERS . " set status = '0', date_status_change = now() where banners_id = '" . $banners_id . "'");
- } else {
- return -1;
- }
- }
-
-////
-// Sets the status of a product
- function tep_set_product_status($products_id, $status) {
- if ($status == '1') {
- return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
- } elseif ($status == '0') {
- return tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '0', products_last_modified = now() where products_id = '" . (int)$products_id . "'");
- } else {
- return -1;
- }
- }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">-////
-// Sets the status of a product on special
- function tep_set_specials_status($specials_id, $status) {
- if ($status == '1') {
- return tep_db_query("update " . TABLE_SPECIALS . " set status = '1', expires_date = NULL, date_status_change = NULL where specials_id = '" . (int)$specials_id . "'");
- } elseif ($status == '0') {
- return tep_db_query("update " . TABLE_SPECIALS . " set status = '0', date_status_change = now() where specials_id = '" . (int)$specials_id . "'");
- } else {
- return -1;
</pre><pre class="diff" id="added">+ $Qclasses = $osC_Database->query('select weight_class_id, weight_class_title from :table_weight_class where language_id = :language_id order by weight_class_title');
+ $Qclasses->bindTable(':table_weight_class', TABLE_WEIGHT_CLASS);
+ $Qclasses->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qclasses->execute();
+
+ while ($Qclasses->next()) {
+ $weight_class_array[] = array('id' => $Qclasses->valueInt('weight_class_id'),
+ 'text' => $Qclasses->value('weight_class_title'));
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="removed">- }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">-////
-// Sets the status of a customer
- function tep_set_customers_status($customers_id, $status) {
- if ($status == '1') {
- return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '1' where customers_id = '" . (int)$customers_id . "'");
- } elseif ($status == '0') {
- return tep_db_query("update " . TABLE_CUSTOMERS . " set customers_status = '0' where customers_id = '" . (int)$customers_id . "'");
- } else {
- return -1;
- }
</pre><pre class="diff" id="added">+ return tep_draw_pull_down_menu($name, $weight_class_array, $weight_class_id);
</pre><pre class="diff" id="context"> }
////
</pre><pre class="diff"><small id="info">@@ -766,29 +635,50 @@
</small></pre><pre class="diff" id="context"> }
function tep_generate_category_path($id, $from = 'category', $categories_array = '', $index = 0) {
</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();
if ($from == 'product') {
</pre><pre class="diff" id="removed">- $categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'");
- while ($categories = tep_db_fetch_array($categories_query)) {
- if ($categories['categories_id'] == '0') {
</pre><pre class="diff" id="added">+ $Qcategories = $osC_Database->query('select categories_id from :table_products_to_categories where products_id = :products_id');
+ $Qcategories->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qcategories->bindInt(':products_id', $id);
+ $Qcategories->execute();
+
+ while ($Qcategories->next()) {
+ if ($Qcategories->valueInt('categories_id') == '0') {
</pre><pre class="diff" id="context"> $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);
} else {
</pre><pre class="diff" id="removed">- $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$osC_Session->value('languages_id') . "'");
- $category = tep_db_fetch_array($category_query);
- $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
- if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
</pre><pre class="diff" id="added">+ $Qcategory = $osC_Database->query('select cd.categories_name, c.parent_id from :table_categories c, :table_categories_description cd where c.categories_id = :categories_id and c.categories_id = cd.categories_id and cd.language_id = :language_id');
+ $Qcategory->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcategory->bindInt(':categories_id', $Qcategories->valueInt('categories_id'));
+ $Qcategory->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qcategory->execute();
+
+ $categories_array[$index][] = array('id' => $Qcategories->valueInt('categories_id'), 'text' => $Qcategory->value('categories_name'));
+
+ if ($Qcategory->valueInt('parent_id') != '0') {
+ $categories_array = tep_generate_category_path($Qcategory->valueInt('parent_id'), 'category', $categories_array, $index);
+ }
+
</pre><pre class="diff" id="context"> $categories_array[$index] = array_reverse($categories_array[$index]);
}
$index++;
}
} elseif ($from == 'category') {
</pre><pre class="diff" id="removed">- $category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$osC_Session->value('languages_id') . "'");
- $category = tep_db_fetch_array($category_query);
- $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
- if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
</pre><pre class="diff" id="added">+ $Qcategory = $osC_Database->query('select cd.categories_name, c.parent_id from :table_categories c, :table_categories_description cd where c.categories_id = :categories_id and c.categories_id = cd.categories_id and cd.language_id = :language_id');
+ $Qcategory->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcategory->bindInt(':categories_id', $id);
+ $Qcategory->bindInt(':language_id', $osC_Session->value('languages_id'));
+ $Qcategory->execute();
+
+ $categories_array[$index][] = array('id' => $id, 'text' => $Qcategory->value('categories_name'));
+
+ if ($Qcategory->valueInt('parent_id') != '0') {
+ $categories_array = tep_generate_category_path($Qcategory->valueInt('parent_id'), 'category', $categories_array, $index);
+ }
</pre><pre class="diff" id="context"> }
return $categories_array;
</pre><pre class="diff"><small id="info">@@ -827,79 +717,289 @@
</small></pre><pre class="diff" id="context"> }
function tep_remove_category($category_id) {
</pre><pre class="diff" id="removed">- $category_image_query = tep_db_query("select categories_image from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
- $category_image = tep_db_fetch_array($category_image_query);
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $Qimage = $osC_Database->query('select categories_image from :table_categories where categories_id = :categories_id');
+ $Qimage->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qimage->bindInt(':categories_id', $category_id);
+ $Qimage->execute();
+
+ $osC_Database->startTransaction();
+
+ $Qc = $osC_Database->query('delete from :table_categories where categories_id = :categories_id');
+ $Qc->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qc->bindInt(':categories_id', $category_id);
+ $Qc->execute();
+
+ if ($osC_Database->isError() === false) {
+ $Qcd = $osC_Database->query('delete from :table_categories_description where categories_id = :categories_id');
+ $Qcd->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
+ $Qcd->bindInt(':categories_id', $category_id);
+ $Qcd->execute();
+
+ if ($osC_Database->isError() === false) {
+ $Qp2c = $osC_Database->query('delete from :table_products_to_categories where categories_id = :categories_id');
+ $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qp2c->bindInt(':categories_id', $category_id);
+ $Qp2c->execute();
+
+ if ($osC_Database->isError() === false) {
+ $osC_Database->commitTransaction();
+
+ osC_Cache::clear('categories');
+ osC_Cache::clear('category_tree');
+ osC_Cache::clear('also_purchased');
+
+ if (tep_not_null($Qimage->value('categories_image'))) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_categories where categories_image = :categories_image');
+ $Qcheck->bindTable(':table_categories', TABLE_CATEGORIES);
+ $Qcheck->bindValue(':categories_image', $Qimage->value('categories_image'));
+ $Qcheck->execute();
+
+ if ($Qcheck->numberOfRows() === 0) {
+ if (file_exists(DIR_FS_CATALOG_IMAGES . $Qimage->value('categories_image'))) {
+ @unlink(DIR_FS_CATALOG_IMAGES . $Qimage->value('categories_image'));
+ }
+ }
+ }
+ } else {
+ $osC_Database->rollbackTransaction();
+ }
+ } else {
+ $osC_Database->rollbackTransaction();
+ }
+ } else {
+ $osC_Database->rollbackTransaction();
+ }
+ }
+
+ function tep_remove_product($product_id) {
+ global $osC_Database;
+
+ $error = false;
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " where categories_image = '" . tep_db_input($category_image['categories_image']) . "'");
- $duplicate_image = tep_db_fetch_array($duplicate_image_query);
</pre><pre class="diff" id="added">+ $Qimage = $osC_Database->query('select products_image from :table_products where products_id = :products_id');
+ $Qimage->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qimage->bindInt(':products_id', $product_id);
+ $Qimage->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if ($duplicate_image['total'] < 2) {
- if (file_exists(DIR_FS_CATALOG_IMAGES . $category_image['categories_image'])) {
- @unlink(DIR_FS_CATALOG_IMAGES . $category_image['categories_image']);
</pre><pre class="diff" id="added">+ $osC_Database->startTransaction();
+
+ $Qr = $osC_Database->query('delete from :table_reviews where products_id = :products_id');
+ $Qr->bindTable(':table_reviews', TABLE_REVIEWS);
+ $Qr->bindInt(':products_id', $product_id);
+ $Qr->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+
+ if ($error === false) {
+ $Qcba = $osC_Database->query('delete from :table_customers_basket_attributes where products_id = :products_id');
+ $Qcba->bindTable(':table_customers_basket_attributes', TABLE_CUSTOMERS_BASKET_ATTRIBUTES);
+ $Qcba->bindInt(':products_id', $product_id);
+ $Qcba->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
</pre><pre class="diff" id="context"> }
}
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
- tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where categories_id = '" . (int)$category_id . "'");
- tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$category_id . "'");
</pre><pre class="diff" id="added">+ if ($error === false) {
+ $Qcb = $osC_Database->query('delete from :table_customers_basket where products_id = :products_id');
+ $Qcb->bindTable(':table_customers_basket', TABLE_CUSTOMERS_BASKET);
+ $Qcb->bindInt(':products_id', $product_id);
+ $Qcb->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- osC_Cache::clear('categories');
- osC_Cache::clear('category_tree');
- osC_Cache::clear('also_purchased');
- }
</pre><pre class="diff" id="added">+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- function tep_remove_product($product_id) {
- $product_image_query = tep_db_query("select products_image from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
- $product_image = tep_db_fetch_array($product_image_query);
</pre><pre class="diff" id="added">+ if ($error === false) {
+ $Qp2c = $osC_Database->query('delete from :table_products_to_categories where products_id = :products_id');
+ $Qp2c->bindTable(':table_products_to_categories', TABLE_PRODUCTS_TO_CATEGORIES);
+ $Qp2c->bindInt(':products_id', $product_id);
+ $Qp2c->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
+
+ if ($error === false) {
+ $Qs = $osC_Database->query('delete from :table_specials where products_id = :products_id');
+ $Qs->bindTable(':table_specials', TABLE_SPECIALS);
+ $Qs->bindInt(':products_id', $product_id);
+ $Qs->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
+
+ if ($error === false) {
+ $Qpa = $osC_Database->query('delete from :table_products_attributes where products_id = :products_id');
+ $Qpa->bindTable(':table_products_attributes', TABLE_PRODUCTS_ATTRIBUTES);
+ $Qpa->bindInt(':products_id', $product_id);
+ $Qpa->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $duplicate_image_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " where products_image = '" . tep_db_input($product_image['products_image']) . "'");
- $duplicate_image = tep_db_fetch_array($duplicate_image_query);
</pre><pre class="diff" id="added">+ if ($error === false) {
+ $Qpd = $osC_Database->query('delete from :table_products_description where products_id = :products_id');
+ $Qpd->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
+ $Qpd->bindInt(':products_id', $product_id);
+ $Qpd->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- if ($duplicate_image['total'] < 2) {
- if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image['products_image'])) {
- @unlink(DIR_FS_CATALOG_IMAGES . $product_image['products_image']);
</pre><pre class="diff" id="added">+ if ($osC_Database->isError() === true) {
+ $error = true;
</pre><pre class="diff" id="context"> }
}
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_SPECIALS . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_PRODUCTS . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET . " where products_id = '" . (int)$product_id . "'");
- tep_db_query("delete from " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " where products_id = '" . (int)$product_id . "'");
</pre><pre class="diff" id="added">+ if ($error === false) {
+ $Qp = $osC_Database->query('delete from :table_products where products_id = :products_id');
+ $Qp->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qp->bindInt(':products_id', $product_id);
+ $Qp->execute();
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- $product_reviews_query = tep_db_query("select reviews_id from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");
- while ($product_reviews = tep_db_fetch_array($product_reviews_query)) {
- tep_db_query("delete from " . TABLE_REVIEWS_DESCRIPTION . " where reviews_id = '" . (int)$product_reviews['reviews_id'] . "'");
</pre><pre class="diff" id="added">+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="removed">- tep_db_query("delete from " . TABLE_REVIEWS . " where products_id = '" . (int)$product_id . "'");
</pre><pre class="diff" id="added">+
+ if ($error === false) {
+ $osC_Database->commitTransaction();
+
+ osC_Cache::clear('categories');
+ osC_Cache::clear('category_tree');
+ osC_Cache::clear('also_purchased');
</pre><pre class="diff" id="context">
</pre><pre class="diff" id="removed">- osC_Cache::clear('categories');
- osC_Cache::clear('category_tree');
- osC_Cache::clear('also_purchased');
</pre><pre class="diff" id="added">+ if (tep_not_null($Qimage->value('products_image'))) {
+ $Qcheck = $osC_Database->query('select count(*) as total from :table_products where products_image = :products_image');
+ $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcheck->bindValue(':products_image', $Qimage->value('products_image'));
+ $Qcheck->execute();
+
+ if ($Qcheck->numberOfRows() === 0) {
+ if (file_exists(DIR_FS_CATALOG_IMAGES . $Qimage->value('products_image'))) {
+ @unlink(DIR_FS_CATALOG_IMAGES . $Qimage->value('products_image'));
+ }
+ }
+ }
+ } else {
+ $osC_Database->rollbackTransaction();
+ }
</pre><pre class="diff" id="context"> }
function tep_remove_order($order_id, $restock = false) {
</pre><pre class="diff" id="added">+ global $osC_Database;
+
+ $error = false;
+
+ $osC_Database->startTransaction();
+
</pre><pre class="diff" id="context"> if ($restock == 'on') {
</pre><pre class="diff" id="removed">- $order_query = tep_db_query("select products_id, products_quantity from " . TABLE_ORDERS_PRODUCTS . " where orders_id = '" . (int)$order_id . "'");
- while ($order = tep_db_fetch_array($order_query)) {
- tep_db_query("update " . TABLE_PRODUCTS . " set products_quantity = products_quantity + " . $order['products_quantity'] . ", products_ordered = products_ordered - " . $order['products_quantity'] . " where products_id = '" . (int)$order['products_id'] . "'");
-
- $products_query = tep_db_query("select products_quantity, products_status from " . TABLE_PRODUCTS . " where products_id = '" . (int)$order['products_id'] . "'");
- $products = tep_db_fetch_array($products_query);
-
- if ($products['products_quantity'] >= '1' && $products['products_status'] == '0') {
- tep_db_query("update " . TABLE_PRODUCTS . " set products_status = '1' where products_id = '" . (int)$order['products_id'] . "'");
</pre><pre class="diff" id="added">+ $Qproducts = $osC_Database->query('select products_id, products_quantity from :table_orders_products where orders_id = :orders_id');
+ $Qproducts->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
+ $Qproducts->bindInt(':orders_id', $order_id);
+ $Qproducts->execute();
+
+ while ($Qproducts->next()) {
+ $Qupdate = $osC_Database->query('update :table_products set products_quantity = products_quantity + :products_quantity, products_ordered = products_ordered - :products_ordered where products_id = :products_id');
+ $Qupdate->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qupdate->bindInt(':products_quantity', $Qproducts->valueInt('products_quantity'));
+ $Qupdate->bindInt(':products_ordered', $Qproducts->valueInt('products_quantity'));
+ $Qupdate->bindInt(':products_id', $Qproducts->valueInt('products_id'));
+ $Qupdate->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ break;
+ }
+
+ $Qcheck = $osC_Database->query('select products_quantity from :table_products where products_id = :products_id and products_Status = 0');
+ $Qcheck->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qcheck->bindInt(':products_id', $Qproducts->valueInt('products_id'));
+ $Qcheck->execute();
+
+ if (($Qcheck->numberOfRows() === 1) && ($Qcheck->valueInt('products_quantity') > 0)) {
+ $Qstatus = $osC_Database->query('update :table_products set products_status = 1 where products_id = :products_id');
+ $Qstatus->bindTable(':table_products', TABLE_PRODUCTS);
+ $Qstatus->bindInt(':products_id', $Qproducts->valueInt('products_id'));
+ $Qstatus->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ break;
+ }
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="added">+ }
+ }
+
+ if ($error === false) {
+ $Qopa = $osC_Database->query('delete from :table_orders_products_attributes where orders_id = :orders_id');
+ $Qopa->bindTable(':table_orders_products_attributes', TABLE_ORDERS_PRODUCTS_ATTRIBUTES);
+ $Qopa->bindInt(':orders_id', $order_id);
+ $Qopa->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
+
+ if ($error === false) {
+ $Qop = $osC_Database->query('delete from :table_orders_products where orders_id = :orders_id');
+ $Qop->bindTable(':table_orders_products', TABLE_ORDERS_PRODUCTS);
+ $Qop->bindInt(':orders_id', $order_id);
+ $Qop->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
+
+ if ($error === false) {
+ $Qosh = $osC_Database->query('delete from :table_orders_status_history where orders_id = :orders_id');
+ $Qosh->bindTable(':table_orders_status_history', TABLE_ORDERS_status_history);
+ $Qosh->bindInt(':orders_id', $order_id);
+ $Qosh->execute();
+
+ if ($osC_Database->isError() === true) {
+ $error = true;
+ }
+ }
+
+ if ($error === false) {
+ $Qot = $osC_Database->query('delete from :table_orders_total where orders_id = :orders_id');
+ $Qot->bindTable(':table_orders_total', TABLE_ORDERS_TOTAL);
+ $Qot->bindInt(':orders_id', $order_id);
+ $Qot->execute();
+
+ if ($osC_Database->isError() === true) {
</pre></pre>
<strong class="error">[truncated at 1000 lines; 224 more skipped]</strong>
</div>
<hr /><a name="file3" /><div class="file">
<span class="pathname"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin">admin</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes">includes</a>/<a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions">functions</a><br /></span>
<div class="fileheader"><big><b>html_output.php</b></big> <small id="info"><a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php?rev=1.33&content-type=text/vnd.viewcvs-markup">1.33</a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php.diff?r1=1.33&r2=1.34">-></a> <a href="http://cvs.oscommerce.com/viewcvs.cgi/admin/admin/includes/functions/html_output.php?rev=1.34&content-type=text/vnd.viewcvs-markup">1.34</a></small></div>
<pre class="diff"><small id="info">diff -u -r1.33 -r1.34
--- html_output.php 2004/08/15 18:12:17 1.33
+++ html_output.php 2004/11/02 00:59:12 1.34
@@ -129,26 +129,42 @@
</small></pre><pre class="diff" id="context"> // javascript to dynamically update the states/provinces list when the country is changed
// TABLES: zones
function tep_js_zone_list($country, $form, $field) {
</pre><pre class="diff" id="removed">- $countries_query = tep_db_query("select distinct zone_country_id from " . TABLE_ZONES . " order by zone_country_id");
</pre><pre class="diff" id="added">+ global $osC_Database;
+
</pre><pre class="diff" id="context"> $num_country = 1;
$output_string = '';
</pre><pre class="diff" id="removed">- while ($countries = tep_db_fetch_array($countries_query)) {
</pre><pre class="diff" id="added">+
+ $Qcountries = $osC_Database->query('select distinct zone_country_id from :table_zones order by zone_country_id');
+ $Qcountries->bindTable(':table_zones', TABLE_ZONES);
+ $Qcountries->execute();
+
+ while ($Qcountries->next()) {
</pre><pre class="diff" id="context"> if ($num_country == 1) {
</pre><pre class="diff" id="removed">- $output_string .= ' if (' . $country . ' == "' . $<span id="removedchars">countries['zone_country_id']</span> . '") {' . "\n";
</pre><pre class="diff" id="added">+ $output_string .= ' if (' . $country . ' == "' . $<span id="addedchars">Qcountries->valueInt('zone_country_id')</span> . '") {' . "\n";
</pre><pre class="diff" id="context"> } else {
</pre><pre class="diff" id="removed">- $output_string .= ' } else if (' . $country . ' == "' . $<span id="removedchars">countries['zone_country_id']</span> . '") {' . "\n";
</pre><pre class="diff" id="added">+ $output_string .= ' } else if (' . $country . ' == "' . $<span id="addedchars">Qcountries->valueInt('zone_country_id')</span> . '") {' . "\n";
</pre><pre class="diff" id="context"> }
</pre><pre class="diff" id="removed">- $states_query = tep_db_query("select zone_name, zone_id from " . TABLE_ZONES . " where zone_country_id = '" . $countries['zone_country_id'] . "' order by zone_name");
-
</pre><pre class="diff" id="context"> $num_state = 1;
</pre><pre class="diff" id="removed">- while ($states = tep_db_fetch_array($states_query)) {
- if ($num_state == '1') $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n";
- $output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $states['zone_name'] . '", "' . $states['zone_id'] . '");' . "\n";
</pre><pre class="diff" id="added">+
+ $Qzones = $osC_Database->query('select zone_name, zone_id from :table_zones where zone_country_id = :zone_country_id order by zone_name');
+ $Qzones->bindTable(':table_zones', TABLE_ZONES);
+ $Qzones->bindInt(':zone_country_id', $Qcountries->valueInt('zone_country_id'));
+ $Qzones->execute();
+
+ while ($Qzones->next()) {
+ if ($num_state == '1') {
+ $output_string .= ' ' . $form . '.' . $field . '.options[0] = new Option("' . PLEASE_SELECT . '", "");' . "\n";
+ }
+
+ $output_string .= ' ' . $form . '.' . $field . '.options[' . $num_state . '] = new Option("' . $Qzones->value('zone_name') . '", "' . $Qzones->valueInt('zone_id') . '");' . "\n";
+
</pre><pre class="diff" id="context"> $num_state++;
}
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context"> $num_country++;
}
</pre><pre class="diff" id="added">+
</pre><pre class="diff" id="context"> $output_string .= ' } else {' . "\n" .
' ' . $form . '.' . $field . '.options[0] = new Option("' . TYPE_BELOW . '", "");' . "\n" .
' }' . "\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>
-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click