[TEP-COMMIT] CVS: catalog/catalog/includes counter.php,1.5,1.6
cvs-OfajU3CKLf1/[email protected] Mon, 16 Feb 2004 08:26:09 +0100
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /pack/cvsroots/oscommerce/catalog/catalog/includes
In directory sunsite.dk:/tmp/cvs-serv6622/includes
Modified Files:
counter.php
Log Message:
use the new database class
Index: counter.php
===================================================================
RCS file: /pack/cvsroots/oscommerce/catalog/catalog/includes/counter.php,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- counter.php 2003/02/10 22:30:52 1.5
+++ counter.php 2004/02/16 07:15:04 1.6
@@ -5,24 +5,38 @@
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
- Copyright (c) 2003 osCommerce
+ Copyright (c) 2004 osCommerce
Released under the GNU General Public License
*/
- $counter_query = tep_db_query("select startdate, counter from " . TABLE_COUNTER);
+ $Qcounter = $osC_Database->query('select startdate, counter from :table_counter');
+ $Qcounter->bindRaw(':table_counter', TABLE_COUNTER);
+ $Qcounter->execute();
- if (!tep_db_num_rows($counter_query)) {
- $date_now = date('Ymd');
- tep_db_query("insert into " . TABLE_COUNTER . " (startdate, counter) values ('" . $date_now . "', '1')");
- $counter_startdate = $date_now;
- $counter_now = 1;
+ if ($Qcounter->numberOfRows()) {
+ $counter_startdate = $Qcounter->value('startdate');
+ $counter_now = $Qcounter->valueInt('counter') + 1;
+
+ $Qcounterupdate = $osC_Database->query('update :table_counter set counter = :counter');
+ $Qcounterupdate->bindRaw(':table_counter', TABLE_COUNTER);
+ $Qcounterupdate->bindInt(':counter', $counter_now);
+ $Qcounterupdate->execute();
+
+ $Qcounterupdate->freeResult();
} else {
- $counter = tep_db_fetch_array($counter_query);
- $counter_startdate = $counter['startdate'];
- $counter_now = ($counter['counter'] + 1);
- tep_db_query("update " . TABLE_COUNTER . " set counter = '" . $counter_now . "'");
+ $counter_startdate = date('Ymd');
+ $counter_now = 1;
+
+ $Qcounterupdate = $osC_Database->query('insert into :table_counter (startdate, counter) values (:start_date, 1)');
+ $Qcounterupdate->bindRaw(':table_counter', TABLE_COUNTER);
+ $Qcounterupdate->bindValue(':start_date', $counter_startdate);
+ $Qcounterupdate->execute();
+
+ $Qcounterupdate->freeResult();
}
+
+ $Qcounter->freeResult();
$counter_startdate_formatted = strftime(DATE_FORMAT_LONG, mktime(0, 0, 0, substr($counter_startdate, 4, 2), substr($counter_startdate, -2), substr($counter_startdate, 0, 4)));
?>
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click