5 * ApplicationLogs class
7 * @http://www.projectpier.org/
9 abstract class BaseApplicationLogs
extends DataManager
{
12 * Column name => Column type map
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
);
22 * @return BaseApplicationLogs
24 function __construct() {
25 parent
::__construct('ApplicationLog', 'application_logs', true);
28 // -------------------------------------------------------
29 // Description methods
30 // -------------------------------------------------------
33 * Return array of object columns
39 function getColumns() {
40 return array_keys(self
::$columns);
47 * @param string $column_name
50 function getColumnType($column_name) {
51 if(isset(self
::$columns[$column_name])) {
52 return self
::$columns[$column_name];
54 return DATA_TYPE_STRING
;
59 * Return array of PK columns. If only one column is PK returns its name as string
63 * @return array or string
65 function getPkColumns() {
70 * Return name of first auto_incremenent column if it exists
76 function getAutoIncrementColumn() {
78 } // getAutoIncrementColumn
80 // -------------------------------------------------------
82 // -------------------------------------------------------
85 * Do a SELECT query over database with specified arguments
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
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);
103 return ApplicationLogs
::instance()->find($arguments);
104 //$instance =& ApplicationLogs::instance();
105 //return $instance->find($arguments);
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);
120 return ApplicationLogs
::instance()->findAll($arguments);
121 //$instance =& ApplicationLogs::instance();
122 //return $instance->findAll($arguments);
127 * Find one specific record
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);
137 return ApplicationLogs
::instance()->findOne($arguments);
138 //$instance =& ApplicationLogs::instance();
139 //return $instance->findOne($arguments);
144 * Return object by its PK value
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);
155 return ApplicationLogs
::instance()->findById($id, $force_reload);
156 //$instance =& ApplicationLogs::instance();
157 //return $instance->findById($id, $force_reload);
162 * Return number of rows in this table
165 * @param string $conditions Query conditions
168 function count($condition = null) {
169 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
170 return parent
::count($condition);
172 return ApplicationLogs
::instance()->count($condition);
173 //$instance =& ApplicationLogs::instance();
174 //return $instance->count($condition);
179 * Delete rows that match specific conditions. If $conditions is NULL all rows from table will be deleted
182 * @param string $conditions Query conditions
185 function delete($condition = null) {
186 if(isset($this) && instance_of($this, 'ApplicationLogs')) {
187 return parent
::delete($condition);
189 return ApplicationLogs
::instance()->delete($condition);
190 //$instance =& ApplicationLogs::instance();
191 //return $instance->delete($condition);
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
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
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);
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);
220 * Return manager instance
222 * @return ApplicationLogs
224 function instance() {
226 if(!instance_of($instance, 'ApplicationLogs')) {
227 $instance = new ApplicationLogs();