[TEP-COMMIT] [CVS catalog] * Introduce support for database transactions (used by MySQL InnoDB table types)
anonymous-OfajU3CKLf1/[email protected] 22 Jul 2004 16:22:14 -0000
| Newsgroups | gmane.comp.web.oscommerce.cvs |
|---|---|
| Message-ID | <[email protected]> |
Commit in catalog/catalog/includes/classes/database on MAIN
mysql_innodb.php +22 added 1.1
mysql.php +41 -1 1.3 -> 1.4
+63 -1
1 added + 1 modified, total 2 files
* Introduce support for database transactions (used by MySQL InnoDB table types)
* Automatically detect SQL_CALC_FOUND_ROWS functionality for MySQL 4.x servers
----------
catalog /catalog /includes /classes /database
mysql_innodb.php added at 1.1
diff -N mysql_innodb.php
--- /dev/null Thu Jul 22 18:22:13 2004
+++ /tmp/cvsAAAL4ayWh Thu Jul 22 18:22:13 2004
@@ -0,0 +1,22 @@
+<?php
+/*
+ $Id$
+
+ osCommerce, Open Source E-Commerce Solutions
+ http://www.oscommerce.com
+
+ Copyright (c) 2004 osCommerce
+
+ Released under the GNU General Public License
+*/
+
+ require('mysql.php');
+
+ class osC_Database_mysql_innodb extends osC_Database_mysql {
+ var $use_transactions = true;
+
+ function osC_Database_mysql_innodb($server, $username, $password) {
+ $this->osC_Database_mysql($server, $username, $password);
+ }
+ }
+?>
----------
catalog /catalog /includes /classes /database
mysql.php 1.3 -> 1.4
diff -u -r1.3 -r1.4
--- mysql.php 2004/04/13 08:09:35 1.3
+++ mysql.php 2004/07/22 16:22:13 1.4
@@ -18,7 +18,8 @@
class osC_Database_mysql extends osC_Database {
var $sql_parse_string = 'addslashes',
- $sql_parse_string_with_connection_handler = false;
+ $sql_parse_string_with_connection_handler = false,
+ $use_transactions = false;
function osC_Database_mysql($server, $username, $password) {
$this->server = $server;
@@ -189,6 +190,45 @@
function affectedRows() {
return mysql_affected_rows($this->link);
+ }
+
+ function startTransaction() {
+ if ($this->use_transactions === true) {
+ return $this->simpleQuery('start transaction');
+ }
+
+ return false;
+ }
+
+ function commitTransaction() {
+ if ($this->use_transactions === true) {
+ return $this->simpleQuery('commit');
+ }
+
+ return false;
+ }
+
+ function rollbackTransaction() {
+ if ($this->use_transactions === true) {
+ return $this->simpleQuery('rollback');
+ }
+
+ return false;
+ }
+
+ function setBatchLimit($sql_query, $from, $maximum_rows) {
+ return $sql_query . ' limit ' . $from . ', ' . $maximum_rows;
+ }
+
+ function batchSize($sql_query) {
+ if (strpos($sql_query, 'SQL_CALC_FOUND_ROWS') !== false) {
+ $bb = $this->query('select found_rows() as total');
+ } else {
+ $total_query = substr($sql_query, 0, strpos($sql_query, ' limit'));
+ $bb = $this->query('select count(*) as total ' . substr($total_query, strpos($sql_query, 'from ')));
+ }
+
+ return $bb->value('total');
}
}
?>
CVSspam 0.2.8
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click