AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / docs / include / classes / DAO / SecondaryResourcesTypesDAO.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 "secondary_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 SecondaryResourcesTypesDAO extends DAO {
25
26         /**
27         * Insert a new row
28         * @access  public
29         * @param   secondary_resource, type_id
30         * @return  table rows
31         * @author  Cindy Qi Li
32         */
33         public function Create($secondary_resource, $type_id)
34         {
35                 $secondary_resource = intval($secondary_resource);
36                 $type_id = intval($type_id);
37
38                 $sql = "INSERT INTO ".TABLE_PREFIX."secondary_resources_types 
39                                 SET secondary_resource_id=$secondary_resource, 
40                                     type_id=$type_id";
41                 return $this->execute($sql);
42         }
43         
44         /**
45         * Delete rows that primary or secondary resource name is the given $resourceName
46         * @access  public
47         * @param   $resourceName: primary or secondary resource name
48         * @return  true or false
49         * @author  Cindy Qi Li
50         */
51         public function DeleteByResourceName($resourceName)
52         {
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);
61         }
62         
63         /**
64         * Return a config row by content_id
65         * @access  public
66         * @param   name
67         * @return  table rows
68         * @author  Cindy Qi Li
69         */
70         public function getByResourceID($resource_id)
71         {
72             $sql = 'SELECT * FROM '.TABLE_PREFIX.'secondary_resources_types WHERE secondary_resource_id='.$resource_id;
73             return $this->execute($sql);
74         }
75 }
76 ?>