AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / include / classes / DAO / ConfigDAO.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 "config" 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 ConfigDAO extends DAO {
25
26         /**
27         * Insert a new config row
28         * @access  public
29         * @param   name, value
30         * @return  table rows
31         * @author  Cindy Qi Li
32         */
33         function Create($name, $value)
34         {
35             $sql = "INSERT INTO ".TABLE_PREFIX."config (name, value)
36                     VALUES ('".$name."', '".$value."')";
37             return $this->execute($sql);
38         }
39         
40         /**
41         * Update a config row
42         * @access  public
43         * @param   name, value
44         * @return  true or false
45         * @author  Cindy Qi Li
46         */
47         function Replace($name, $value)
48         {
49             $sql = "REPLACE INTO ".TABLE_PREFIX."config 
50                      VALUES ('".$name."', '".$value."')";
51             return $this->execute($sql);
52         }
53         
54         /**
55         * Delete a config row
56         * @access  public
57         * @param   name
58         * @return  true or false
59         * @author  Cindy Qi Li
60         */
61         function Delete($name)
62         {
63             $sql = "DELETE FROM ".TABLE_PREFIX."config 
64                      WHERE name = '".$name."'";
65             return $this->execute($sql);
66         }
67         
68         /**
69         * Return all config' information
70         * @access  public
71         * @param   none
72         * @return  table rows
73         * @author  Cindy Qi Li
74         */
75         function getAll()
76         {
77             $sql = 'SELECT * FROM '.TABLE_PREFIX.'config ORDER BY name';
78             return $this->execute($sql);
79         }
80
81         /**
82         * Return a config row by name
83         * @access  public
84         * @param   name
85         * @return  table rows
86         * @author  Cindy Qi Li
87         */
88         function get($name)
89         {
90             $sql = "SELECT * FROM ".TABLE_PREFIX."config WHERE name = '".$name."'";
91             $rows = $this->execute($sql);
92             return $rows[0];
93         }
94 }
95 ?>