Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

1319
 
1372
 
1372
 
database.php
_> 11 <?php
  22 /*
<> 3 -  $Id: database.php 1319 2007-03-05 20:43:07Z hpdl $
   3+  $Id: database.php 1372 2007-03-05 22:58:51Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
  77 
<> 8 -  Copyright (c) 2006 osCommerce
   8+  Copyright (c) 2007 osCommerce
99 
  1010   Released under the GNU General Public License
  1111 */
     
 !
2222         $password,
  2323         $debug = false,
  2424         $number_of_queries = 0,
<> 25 -        $time_of_queries = 0;
   25+        $time_of_queries = 0,
   26+        $nextID = null,
   27+        $logging_transaction = false,
   28+        $logging_transaction_action = false;
2629 
  2730     function &connect($server, $username, $password, $type = DB_DATABASE_CLASS) {
  2831       require('database/' . $type . '.php');
     
 !
290293         $batch_size,
  291294         $batch_to,
  292295         $batch_from,
<> 293 -        $batch_select_field;
   296+        $batch_select_field,
   297+        $logging = false,
   298+        $logging_module,
   299+        $logging_module_id,
   300+        $logging_fields = array(),
   301+        $logging_changed = array();
294302 
  295303     function osC_Database_Result(&$db_class) {
  296304       $this->db_class =& $db_class;
     
 !
353361       return $this->valueMixed($column, 'decimal');
  354362     }
  355363 
<> 356 -    function bindValueMixed($place_holder, $value, $type = 'string') {
   364+    function bindValueMixed($place_holder, $value, $type = 'string', $log = true) {
   365+      if ($log === true) {
   366+        $this->logging_fields[substr($place_holder, 1)] = $value;
   367+      }
   368+
357369       switch ($type) {
  358370         case 'int':
  359371           $value = intval($value);
     
 !
401413     }
  402414 
  403415     function bindTable($place_holder, $value) {
<> 404 -      $this->bindValueMixed($place_holder, $value, 'raw');
   416+      $this->bindValueMixed($place_holder, $value, 'raw', false);
405417     }
  406418 
  407419     function next() {
     
 !
478490       }
  479491 
  480492       if ($this->cache_read === false) {
<>  493+        if ($this->logging === true) {
   494+          $this->logging_action = substr($this->sql_query, 0, strpos($this->sql_query, ' '));
   495+
   496+          if ($this->logging_action == 'update') {
   497+            $db = split(' ', $this->sql_query, 3);
   498+            $this->logging_database = $db[1];
   499+
   500+            $test = $this->db_class->simpleQuery('select ' . implode(', ', array_keys($this->logging_fields)) . ' from ' . $this->logging_database . substr($this->sql_query, osc_strrpos_string($this->sql_query, ' where ')));
   501+
   502+            while ($result = $this->db_class->next($test)) {
   503+              foreach ($this->logging_fields as $key => $value) {
   504+                if ($result[$key] != $value) {
   505+                  $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $result[$key], 'new' => $value);
   506+                }
   507+              }
   508+            }
   509+          } elseif ($this->logging_action == 'insert') {
   510+            $db = split(' ', $this->sql_query, 4);
   511+            $this->logging_database = $db[2];
   512+
   513+            foreach ($this->logging_fields as $key => $value) {
   514+              $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => '', 'new' => $value);
   515+            }
   516+          } elseif ($this->logging_action == 'delete') {
   517+            $db = split(' ', $this->sql_query, 4);
   518+            $this->logging_database = $db[2];
   519+
   520+            $del = $this->db_class->simpleQuery('select * from ' . $this->logging_database . ' ' . $db[3]);
   521+            while ($result = $this->db_class->next($del)) {
   522+              foreach ($result as $key => $value) {
   523+                $this->logging_changed[] = array('key' => $this->logging_database . '.' . $key, 'old' => $value, 'new' => '');
   524+              }
   525+            }
   526+          }
   527+        }
   528+
481529         $this->query_handler = $this->db_class->simpleQuery($this->sql_query, $this->debug);
  482530 
<>  531+        if ($this->logging === true) {
   532+          if ($this->db_class->logging_transaction_action === false) {
   533+            $this->db_class->logging_transaction_action = $this->logging_action;
   534+          }
   535+
   536+          if ($this->affectedRows($this->query_handler) > 0) {
   537+            if (!empty($this->logging_changed)) {
   538+              if ( ($this->logging_action == 'insert') && !is_numeric($this->logging_module_id) ) {
   539+                $this->logging_module_id = $this->db_class->nextID();
   540+                $this->setNextID($this->logging_module_id);
   541+              }
   542+
   543+              if ( class_exists('osC_AdministratorsLog') ) {
   544+                osC_AdministratorsLog::insert($this->logging_module, $this->db_class->logging_transaction_action, $this->logging_module_id, $this->logging_action, $this->logging_changed, $this->db_class->logging_transaction);
   545+              }
   546+            }
   547+          }
   548+        }
   549+
483550         if ($this->batch_query === true) {
  484551           $this->getBatchSize();
  485552 
     
 !
513580       $this->cache_expire = $expire;
  514581     }
  515582 
<>  583+    function setLogging($module, $id = null) {
   584+      $this->logging = true;
   585+      $this->logging_module = $module;
   586+      $this->logging_module_id = $id;
   587+    }
   588+
   589+    function setNextID($id) {
   590+      $this->db_class->nextID = $id;
   591+    }
   592+
<_ 516593     function toArray() {
  517594       if (!isset($this->result)) {
  518595         $this->next();