phpOpenTracker/phpOpenTracker/DB mysql_merge.php,1.22.2.8,1.22.2.9
Sebastian Bergmann <[email protected]> Mon, 12 Apr 2004 08:42:52 +0000
| Newsgroups | gmane.comp.web.phpopentracker.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/DB
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5056
Modified Files:
Tag: phpOpenTracker_1
mysql_merge.php
Log Message:
Rewrite query() method.
Index: mysql_merge.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/DB/Attic/mysql_merge.php,v
retrieving revision 1.22.2.8
retrieving revision 1.22.2.9
diff -u -d -r1.22.2.8 -r1.22.2.9
--- mysql_merge.php 12 Apr 2004 08:17:42 -0000 1.22.2.8
+++ mysql_merge.php 12 Apr 2004 08:42:49 -0000 1.22.2.9
@@ -85,48 +85,46 @@
* @access public
*/
function query($query, $limit = false, $warnOnFailure = true, $tablesAlreadyCreated = false) {
- $insert = false;
-
- if (!$tablesAlreadyCreated &&
- strstr($query, 'INSERT')) {
- $insert = true;
-
- $query = $this->_replaceTableNames($query);
- } else {
- $query = $this->_rewriteSelectQuery($query);
+ if ($this->isManip($query)) {
+ if (!$tablesAlreadyCreated) {
+ $query = $this->_replaceTableNames($query);
+ }
- if ($limit != false) {
- $query .= ' LIMIT ' . $limit;
+ if (isset($this->result) && is_resource($this->result)) {
+ @mysql_free_result($this->result);
}
- }
- if ($this->config['debug_level'] > 1) {
- $this->debugQuery($query);
- }
+ if ($this->config['debug_level'] > 1) {
+ $this->debugQuery($query);
+ }
- if (isset($this->result) && is_resource($this->result)) {
- @mysql_free_result($this->result);
- }
+ $this->result = @mysql_query($query, $this->connection);
- $this->result = @mysql_unbuffered_query($query, $this->connection);
+ if (!$this->result) {
+ $throwError = $warnOnFailure ? true : false;
- if (!$this->result) {
- $throwError = $warnOnFailure ? true : false;
+ if (!$tablesAlreadyCreated &&
+ mysql_errno($this->connection) == 1146) {
+ $this->_createNewTables();
+ $this->query($query, $limit, $warnOnFailure, true);
+ $throwError = false;
+ }
- if ($insert &&
- !$tablesAlreadyCreated &&
- mysql_errno($this->connection) == 1146) {
- $this->_createNewTables();
- $this->query($query, $limit, $warnOnFailure, true);
- $throwError = false;
+ if ($throwError) {
+ phpOpenTracker::handleError(
+ @mysql_error($this->connection),
+ E_USER_ERROR
+ );
+ }
}
+ } else {
+ $query = $this->_rewriteSelectQuery($query);
- if ($throwError) {
- phpOpenTracker::handleError(
- @mysql_error($this->connection),
- E_USER_ERROR
- );
+ if ($limit != false) {
+ $query .= ' LIMIT ' . $limit;
}
+
+ parent::query($query);
}
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click