first import
[projectpier.git] / application / models / application_logs / base / BaseApplicationLogs.class.php
blob1589d7069739422a17807bafd39be710dc7559de
1 <?php
4 /**
5 * ApplicationLogs class
7 * @http://www.projectpier.org/
8 */
9 abstract class BaseApplicationLogs extends DataManager {
11 /**
12 * Column name => Column type map
14 * @var array
15 * @static
17 static private $columns = array('id' => DATA_TYPE_INTEGER, 'taken_by_id' => DATA_TYPE_INTEGER, 'project_id' => DATA_TYPE_INTEGER, 'rel_object_id' => DATA_TYPE_INTEGER, 'object_name' => DATA_TYPE_STRING, 'rel_object_manager' => DATA_TYPE_STRING, 'created_on' => DATA_TYPE_DATETIME, 'created_by_id' => DATA_TYPE_INTEGER, 'action' => DATA_TYPE_STRING, 'is_private' => DATA_TYPE_BOOLEAN, 'is_silent' => DATA_TYPE_BOOLEAN);
19 /**
20 * Construct
22 * @return BaseApplicationLogs
24 function __construct() {
25 parent::__construct('ApplicationLog', 'application_logs', true);
26 } // __construct
28 // -------------------------------------------------------
29 // Description methods
30 // -------------------------------------------------------
32 /**
33 * Return array of object columns
35 * @access public
36 * @param void
37 * @return array
39 function getColumns() {
40 return array_keys(self::$columns);
41 } // getColumns
43 /**
44 * Return column type
46 * @access public
47 * @param string $column_name
48 * @return string
50 function getColumnType($column_name) {
51 if(isset(self::$columns[$column_name])) {
52 return self::$columns[$column_name];
53 } else {
54 return DATA_TYPE_STRING;
55 } // if
56 } // getColumnType
58 /**
59 * Return array of PK columns. If only one column is PK returns its name as string
61 * @access public
62 * @param void
63 * @return array or string
65 function getPkColumns() {
66 return 'id';
67 } // getPkColumns
69 /**
70 * Return name of first auto_incremenent column if it exists
72 * @access public
73 * @param void
74 * @return string
76 function getAutoIncrementColumn() {
77 return 'id';
78 } // getAutoIncrementColumn
80 // -------------------------------------------------------
81 // Finders
82 // -------------------------------------------------------
84 /**
85 * Do a SELECT query over database with specified arguments
87 * @access public
88 * @param array $arguments Array of query arguments. Fields:
90 * - one - select first row
91 * - conditions - additional conditions
92 * - order - order by string
93 * - offset - limit offset, valid only if limit is present
94 * - limit
96 * @return one or ApplicationLogs objects
97 * @throws DBQueryError
99 function find($arguments = null) {
100 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
101 return parent::find($arguments);
102 } else {
103 return ApplicationLogs::instance()->find($arguments);
104 //$instance =& ApplicationLogs::instance();
105 //return $instance->find($arguments);
106 } // if
107 } // find
110 * Find all records
112 * @access public
113 * @param array $arguments
114 * @return one or ApplicationLogs objects
116 function findAll($arguments = null) {
117 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
118 return parent::findAll($arguments);
119 } else {
120 return ApplicationLogs::instance()->findAll($arguments);
121 //$instance =& ApplicationLogs::instance();
122 //return $instance->findAll($arguments);
123 } // if
124 } // findAll
127 * Find one specific record
129 * @access public
130 * @param array $arguments
131 * @return ApplicationLog
133 function findOne($arguments = null) {
134 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
135 return parent::findOne($arguments);
136 } else {
137 return ApplicationLogs::instance()->findOne($arguments);
138 //$instance =& ApplicationLogs::instance();
139 //return $instance->findOne($arguments);
140 } // if
141 } // findOne
144 * Return object by its PK value
146 * @access public
147 * @param mixed $id
148 * @param boolean $force_reload If true cache will be skipped and data will be loaded from database
149 * @return ApplicationLog
151 function findById($id, $force_reload = false) {
152 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
153 return parent::findById($id, $force_reload);
154 } else {
155 return ApplicationLogs::instance()->findById($id, $force_reload);
156 //$instance =& ApplicationLogs::instance();
157 //return $instance->findById($id, $force_reload);
158 } // if
159 } // findById
162 * Return number of rows in this table
164 * @access public
165 * @param string $conditions Query conditions
166 * @return integer
168 function count($condition = null) {
169 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
170 return parent::count($condition);
171 } else {
172 return ApplicationLogs::instance()->count($condition);
173 //$instance =& ApplicationLogs::instance();
174 //return $instance->count($condition);
175 } // if
176 } // count
179 * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted
181 * @access public
182 * @param string $conditions Query conditions
183 * @return boolean
185 function delete($condition = null) {
186 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
187 return parent::delete($condition);
188 } else {
189 return ApplicationLogs::instance()->delete($condition);
190 //$instance =& ApplicationLogs::instance();
191 //return $instance->delete($condition);
192 } // if
193 } // delete
196 * This function will return paginated result. Result is an array where first element is
197 * array of returned object and second populated pagination object that can be used for
198 * obtaining and rendering pagination data using various helpers.
200 * Items and pagination array vars are indexed with 0 for items and 1 for pagination
201 * because you can't use associative indexing with list() construct
203 * @access public
204 * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
205 * @param integer $items_per_page Number of items per page
206 * @param integer $current_page Current page number
207 * @return array
209 function paginate($arguments = null, $items_per_page = 10, $current_page = 1) {
210 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
211 return parent::paginate($arguments, $items_per_page, $current_page);
212 } else {
213 return ApplicationLogs::instance()->paginate($arguments, $items_per_page, $current_page);
214 //$instance =& ApplicationLogs::instance();
215 //return $instance->paginate($arguments, $items_per_page, $current_page);
216 } // if
217 } // paginate
220 * Return manager instance
222 * @return ApplicationLogs
224 function instance() {
225 static $instance;
226 if(!instance_of($instance, 'ApplicationLogs')) {
227 $instance = new ApplicationLogs();
228 } // if
229 return $instance;
230 } // instance
232 } // ApplicationLogs