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 "primary_resources_types" table
20 if (!defined('TR_INCLUDE_PATH')) exit;
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
24 class PrimaryResourcesTypesDAO extends DAO {
29 * @param primary_resource_id, type_id
30 * @return true, if successful; false, otherwise
33 public function Create($primary_resource_id, $type_id)
35 $primary_resource_id= intval($primary_resource_id);
36 $type_id = intval($type_id);
38 $sql = "INSERT INTO ".TABLE_PREFIX."primary_resources_types
39 SET primary_resource_id=$primary_resource_id,
41 return $this->execute($sql);
45 * Delete rows that primary resource name is the given $resourceName
47 * @param $resourceName: primary resource name
48 * @return true or false
51 function DeleteByResourceName($resourceName)
53 $sql = "DELETE FROM ".TABLE_PREFIX."primary_resources_types
54 WHERE primary_resource_id in (SELECT primary_resource_id
55 FROM ".TABLE_PREFIX."primary_resources
56 WHERE resource = '".$resourceName."')";
57 return $this->execute($sql);
61 * Return a config row by content_id
67 public function getByResourceID($resource_id)
69 $sql = 'SELECT * FROM '.TABLE_PREFIX.'primary_resources_types WHERE primary_resource_id='.$resource_id;
70 return $this->execute($sql);