moved code up one level to eliminate the docs subdirectory
[acontent.git] / include / classes / DAO / PrimaryResourcesTypesDAO.class.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
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 /************************************************************************/
12
13 /**
14 * DAO for "primary_resources_types" table
15 * @access       public
16 * @author       Cindy Qi Li
17 * @package      DAO
18 */
19
20 if (!defined('TR_INCLUDE_PATH')) exit;
21
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
23
24 class PrimaryResourcesTypesDAO extends DAO {
25
26         /**
27         * Insert a new row
28         * @access  public
29         * @param   primary_resource_id, type_id
30         * @return  true, if successful; false, otherwise
31         * @author  Cindy Qi Li
32         */
33         public function Create($primary_resource_id, $type_id)
34         {
35                 $primary_resource_id= intval($primary_resource_id);
36                 $type_id = intval($type_id);
37
38                 $sql = "INSERT INTO ".TABLE_PREFIX."primary_resources_types 
39                                 SET primary_resource_id=$primary_resource_id, 
40                                     type_id=$type_id";
41                 return $this->execute($sql);
42         }
43         
44         /**
45         * Delete rows that primary resource name is the given $resourceName
46         * @access  public
47         * @param   $resourceName: primary resource name
48         * @return  true or false
49         * @author  Cindy Qi Li
50         */
51         function DeleteByResourceName($resourceName)
52         {
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);
58         }
59         
60         /**
61         * Return a config row by content_id
62         * @access  public
63         * @param   name
64         * @return  table rows
65         * @author  Cindy Qi Li
66         */
67         public function getByResourceID($resource_id)
68         {
69             $sql = 'SELECT * FROM '.TABLE_PREFIX.'primary_resources_types WHERE primary_resource_id='.$resource_id;
70             return $this->execute($sql);
71         }
72 }
73 ?>