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