2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
8 /* This program is free software. You can redistribute it and/or */
9 /* modify it under the terms of the GNU General Public License */
10 /* as published by the Free Software Foundation. */
11 /************************************************************************/
14 * DAO for "patches_files" table
20 if (!defined('TR_INCLUDE_PATH')) exit;
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
24 class PatchesFilesDAO extends DAO {
29 * @param patch_id, action, $name, $location
30 * @return patches_files_id, if successful
31 * false and add error into global var $msg, if unsuccessful
34 public function Create($patch_id, $action, $name, $location)
38 $sql = "INSERT INTO " . TABLE_PREFIX. "patches_files " .
46 '".$addslashes($name)."',
47 '".$addslashes($location)."')";
49 if (!$this->execute($sql))
51 $msg->addError('DB_NOT_UPDATED');
56 return mysql_insert_id();
61 * Return number of times that the given file have been updated by Updater
63 * @param $file: file name
64 * @return number of times
67 public function getNumOfUpdatesOnFile($file)
69 $sql = "SELECT count(*) num_of_updates FROM " . TABLE_PREFIX. "patches patches, " . TABLE_PREFIX."patches_files patches_files " .
70 "WHERE patches.applied_version = '" . VERSION . "' ".
71 " AND patches.status = 'Installed' " .
72 " AND patches.patches_id = patches_files.patches_id " .
73 " AND patches_files.name = '" . $file . "'";
75 return $this->execute($sql);