Ignore:
Timestamp:
Dec 30, 2014 10:24:51 PM (9 years ago)
Author:
anonymous
Message:

Many minor fixes during pulso development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Version.inc.php

    r497 r502  
    3737 * @version 2.1
    3838 */
    39 class Version {
     39class Version
     40{
    4041
    4142    // A place to keep an object instance for the singleton pattern.
     
    290291        }
    291292
    292         // Replace current record with specified versioned record.
     293        // Disable foreign_key_checks to prevent ON DELETE triggers or restrictions.
     294        $db->query("SET SESSION foreign_key_checks = 0");
     295        // Replace current record with specified versioned record. Consider converting this SQL to use INSERT 
 ON DUPLICATE KEY UPDATE 

    293296        $db->query("
    294             REPLACE INTO " . $record['record_table'] . " (
     297        REPLACE INTO " . $record['record_table'] . " (
    295298                $replace_keys
    296299            ) VALUES (
    297300                $replace_values
    298             )
    299         ");
     301            );
     302        ");
     303        // Re-enable foreign_key_checks.
     304        $db->query("SET SESSION foreign_key_checks = 1");
    300305
    301306        return $record;
     
    468473    {
    469474        $db =& DB::getInstance();
    470 
    471         $this->initDB();
     475        $app =& App::getInstance();
     476
     477        $this->initDB();
     478
     479        if (!$record_table || !$record_key || !$record_val) {
     480            $app->logMsg(sprintf('Invalid current version args: %s, %s, %s.', $record_table, $record_key, $record_val), LOG_ERR, __FILE__, __LINE__);
     481            return false;
     482        }
    472483
    473484        $qid = $db->query("
Note: See TracChangeset for help on using the changeset viewer.