summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--backend/php/src/objects/class.record.php2
1 files changed, 1 insertions, 1 deletions
diff --git a/backend/php/src/objects/class.record.php b/backend/php/src/objects/class.record.php
index 37a9702..2ab5c4a 100644
--- a/backend/php/src/objects/class.record.php
+++ b/backend/php/src/objects/class.record.php
@@ -1,441 +1,441 @@
1<?php 1<?php
2/* 2/*
3 This SQL query will create the table to store your object. 3 This SQL query will create the table to store your object.
4 4
5 CREATE TABLE `record` ( 5 CREATE TABLE `record` (
6 `recordid` int(11) NOT NULL auto_increment, 6 `recordid` int(11) NOT NULL auto_increment,
7 `userid` int(11) NOT NULL, 7 `userid` int(11) NOT NULL,
8 `reference` VARCHAR(255) NOT NULL, 8 `reference` VARCHAR(255) NOT NULL,
9 `data` LONGTEXT NOT NULL, 9 `data` LONGTEXT NOT NULL,
10 `version` VARCHAR(255) NOT NULL, 10 `version` VARCHAR(255) NOT NULL,
11 `creation_date` TIMESTAMP NOT NULL, 11 `creation_date` TIMESTAMP NOT NULL,
12 `update_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 12 `update_date` TIMESTAMP NOT NULL,
13 `access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY (`recordid`)) ENGINE=MyISAM; 13 `access_date` TIMESTAMP NOT NULL, INDEX(`userid`), PRIMARY KEY (`recordid`)) ENGINE=MyISAM;
14*/ 14*/
15 15
16/** 16/**
17* <b>record</b> class with integrated CRUD methods. 17* <b>record</b> class with integrated CRUD methods.
18* @author Php Object Generator 18* @author Php Object Generator
19* @version POG 3.0e / PHP5.1 MYSQL 19* @version POG 3.0e / PHP5.1 MYSQL
20* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql 20* @see http://www.phpobjectgenerator.com/plog/tutorials/45/pdo-mysql
21* @copyright Free for personal & commercial use. (Offered under the BSD license) 21* @copyright Free for personal & commercial use. (Offered under the BSD license)
22* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=record&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27recordversion%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27creation_date%27%2C%0A++6+%3D%3E+%27update_date%27%2C%0A++7+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529 22* @link http://www.phpobjectgenerator.com/?language=php5.1&wrapper=pdo&pdoDriver=mysql&objectName=record&attributeList=array+%28%0A++0+%3D%3E+%27user%27%2C%0A++1+%3D%3E+%27recordversion%27%2C%0A++2+%3D%3E+%27reference%27%2C%0A++3+%3D%3E+%27data%27%2C%0A++4+%3D%3E+%27version%27%2C%0A++5+%3D%3E+%27creation_date%27%2C%0A++6+%3D%3E+%27update_date%27%2C%0A++7+%3D%3E+%27access_date%27%2C%0A%29&typeList=array%2B%2528%250A%2B%2B0%2B%253D%253E%2B%2527BELONGSTO%2527%252C%250A%2B%2B1%2B%253D%253E%2B%2527HASMANY%2527%252C%250A%2B%2B2%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B3%2B%253D%253E%2B%2527LONGTEXT%2527%252C%250A%2B%2B4%2B%253D%253E%2B%2527VARCHAR%2528255%2529%2527%252C%250A%2B%2B5%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B6%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2B%2B7%2B%253D%253E%2B%2527TIMESTAMP%2527%252C%250A%2529
23*/ 23*/
24include_once('class.pog_base.php'); 24include_once('class.pog_base.php');
25class record extends POG_Base 25class record extends POG_Base
26{ 26{
27 public $recordId = ''; 27 public $recordId = '';
28 28
29 /** 29 /**
30 * @var INT(11) 30 * @var INT(11)
31 */ 31 */
32 public $userId; 32 public $userId;
33 33
34 /** 34 /**
35 * @var private array of recordversion objects 35 * @var private array of recordversion objects
36 */ 36 */
37 private $_recordversionList = array(); 37 private $_recordversionList = array();
38 38
39 /** 39 /**
40 * @var VARCHAR(255) 40 * @var VARCHAR(255)
41 */ 41 */
42 public $reference; 42 public $reference;
43 43
44 /** 44 /**
45 * @var LONGTEXT 45 * @var LONGTEXT
46 */ 46 */
47 public $data; 47 public $data;
48 48
49 /** 49 /**
50 * @var VARCHAR(255) 50 * @var VARCHAR(255)
51 */ 51 */
52 public $version; 52 public $version;
53 53
54 /** 54 /**
55 * @var TIMESTAMP 55 * @var TIMESTAMP
56 */ 56 */
57 public $creation_date; 57 public $creation_date;
58 58
59 /** 59 /**
60 * @var TIMESTAMP 60 * @var TIMESTAMP
61 */ 61 */
62 public $update_date; 62 public $update_date;
63 63
64 /** 64 /**
65 * @var TIMESTAMP 65 * @var TIMESTAMP
66 */ 66 */
67 public $access_date; 67 public $access_date;
68 68
69 public $pog_attribute_type = array( 69 public $pog_attribute_type = array(
70 "recordId" => array('db_attributes' => array("NUMERIC", "INT")), 70 "recordId" => array('db_attributes' => array("NUMERIC", "INT")),
71 "user" => array('db_attributes' => array("OBJECT", "BELONGSTO")), 71 "user" => array('db_attributes' => array("OBJECT", "BELONGSTO")),
72 "recordversion" => array('db_attributes' => array("OBJECT", "HASMANY")), 72 "recordversion" => array('db_attributes' => array("OBJECT", "HASMANY")),
73 "reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")), 73 "reference" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
74 "data" => array('db_attributes' => array("TEXT", "LONGTEXT")), 74 "data" => array('db_attributes' => array("TEXT", "LONGTEXT")),
75 "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")), 75 "version" => array('db_attributes' => array("TEXT", "VARCHAR", "255")),
76 "creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")), 76 "creation_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
77 "update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")), 77 "update_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
78 "access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")), 78 "access_date" => array('db_attributes' => array("NUMERIC", "TIMESTAMP")),
79 ); 79 );
80 public $pog_query; 80 public $pog_query;
81 81
82 82
83 /** 83 /**
84 * Getter for some private attributes 84 * Getter for some private attributes
85 * @return mixed $attribute 85 * @return mixed $attribute
86 */ 86 */
87 public function __get($attribute) 87 public function __get($attribute)
88 { 88 {
89 if (isset($this->{"_".$attribute})) 89 if (isset($this->{"_".$attribute}))
90 { 90 {
91 return $this->{"_".$attribute}; 91 return $this->{"_".$attribute};
92 } 92 }
93 else 93 else
94 { 94 {
95 return false; 95 return false;
96 } 96 }
97 } 97 }
98 98
99 function record($reference='', $data='', $version='', $creation_date='', $update_date='', $access_date='') 99 function record($reference='', $data='', $version='', $creation_date='', $update_date='', $access_date='')
100 { 100 {
101 $this->_recordversionList = array(); 101 $this->_recordversionList = array();
102 $this->reference = $reference; 102 $this->reference = $reference;
103 $this->data = $data; 103 $this->data = $data;
104 $this->version = $version; 104 $this->version = $version;
105 $this->creation_date = $creation_date; 105 $this->creation_date = $creation_date;
106 $this->update_date = $update_date; 106 $this->update_date = $update_date;
107 $this->access_date = $access_date; 107 $this->access_date = $access_date;
108 } 108 }
109 109
110 110
111 /** 111 /**
112 * Gets object from database 112 * Gets object from database
113 * @param integer $recordId 113 * @param integer $recordId
114 * @return object $record 114 * @return object $record
115 */ 115 */
116 function Get($recordId) 116 function Get($recordId)
117 { 117 {
118 $connection = Database::Connect(); 118 $connection = Database::Connect();
119 $this->pog_query = "select * from `record` where `recordid`='".intval($recordId)."' LIMIT 1"; 119 $this->pog_query = "select * from `record` where `recordid`='".intval($recordId)."' LIMIT 1";
120 $cursor = Database::Reader($this->pog_query, $connection); 120 $cursor = Database::Reader($this->pog_query, $connection);
121 while ($row = Database::Read($cursor)) 121 while ($row = Database::Read($cursor))
122 { 122 {
123 $this->recordId = $row['recordid']; 123 $this->recordId = $row['recordid'];
124 $this->userId = $row['userid']; 124 $this->userId = $row['userid'];
125 $this->reference = $this->Unescape($row['reference']); 125 $this->reference = $this->Unescape($row['reference']);
126 $this->data = $this->Unescape($row['data']); 126 $this->data = $this->Unescape($row['data']);
127 $this->version = $this->Unescape($row['version']); 127 $this->version = $this->Unescape($row['version']);
128 $this->creation_date = $row['creation_date']; 128 $this->creation_date = $row['creation_date'];
129 $oDate = strtotime($row['update_date']); 129 $oDate = strtotime($row['update_date']);
130 $this->update_date = date('r', $oDate); 130 $this->update_date = date('r', $oDate);
131 $this->access_date = $row['access_date']; 131 $this->access_date = $row['access_date'];
132 } 132 }
133 return $this; 133 return $this;
134 } 134 }
135 135
136 136
137 /** 137 /**
138 * Returns a sorted array of objects that match given conditions 138 * Returns a sorted array of objects that match given conditions
139 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 139 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
140 * @param string $sortBy 140 * @param string $sortBy
141 * @param boolean $ascending 141 * @param boolean $ascending
142 * @param int limit 142 * @param int limit
143 * @return array $recordList 143 * @return array $recordList
144 */ 144 */
145 function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='') 145 function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
146 { 146 {
147 $connection = Database::Connect(); 147 $connection = Database::Connect();
148 $sqlLimit = ($limit != '' ? "LIMIT $limit" : ''); 148 $sqlLimit = ($limit != '' ? "LIMIT $limit" : '');
149 $this->pog_query = "select * from `record` "; 149 $this->pog_query = "select * from `record` ";
150 $recordList = Array(); 150 $recordList = Array();
151 if (sizeof($fcv_array) > 0) 151 if (sizeof($fcv_array) > 0)
152 { 152 {
153 $this->pog_query .= " where "; 153 $this->pog_query .= " where ";
154 for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) 154 for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
155 { 155 {
156 if (sizeof($fcv_array[$i]) == 1) 156 if (sizeof($fcv_array[$i]) == 1)
157 { 157 {
158 $this->pog_query .= " ".$fcv_array[$i][0]." "; 158 $this->pog_query .= " ".$fcv_array[$i][0]." ";
159 continue; 159 continue;
160 } 160 }
161 else 161 else
162 { 162 {
163 if ($i > 0 && sizeof($fcv_array[$i-1]) != 1) 163 if ($i > 0 && sizeof($fcv_array[$i-1]) != 1)
164 { 164 {
165 $this->pog_query .= " AND "; 165 $this->pog_query .= " AND ";
166 } 166 }
167 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') 167 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
168 { 168 {
169 if ($GLOBALS['configuration']['db_encoding'] == 1) 169 if ($GLOBALS['configuration']['db_encoding'] == 1)
170 { 170 {
171 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'"; 171 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'";
172 $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value; 172 $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value;
173 } 173 }
174 else 174 else
175 { 175 {
176 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'"; 176 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'";
177 $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; 177 $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
178 } 178 }
179 } 179 }
180 else 180 else
181 { 181 {
182 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'"; 182 $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'";
183 $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; 183 $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value;
184 } 184 }
185 } 185 }
186 } 186 }
187 } 187 }
188 if ($sortBy != '') 188 if ($sortBy != '')
189 { 189 {
190 if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') 190 if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET')
191 { 191 {
192 if ($GLOBALS['configuration']['db_encoding'] == 1) 192 if ($GLOBALS['configuration']['db_encoding'] == 1)
193 { 193 {
194 $sortBy = "BASE64_DECODE($sortBy) "; 194 $sortBy = "BASE64_DECODE($sortBy) ";
195 } 195 }
196 else 196 else
197 { 197 {
198 $sortBy = "$sortBy "; 198 $sortBy = "$sortBy ";
199 } 199 }
200 } 200 }
201 else 201 else
202 { 202 {
203 $sortBy = "$sortBy "; 203 $sortBy = "$sortBy ";
204 } 204 }
205 } 205 }
206 else 206 else
207 { 207 {
208 $sortBy = "recordid"; 208 $sortBy = "recordid";
209 } 209 }
210 $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit"; 210 $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit";
211 $thisObjectName = get_class($this); 211 $thisObjectName = get_class($this);
212 $cursor = Database::Reader($this->pog_query, $connection); 212 $cursor = Database::Reader($this->pog_query, $connection);
213 while ($row = Database::Read($cursor)) 213 while ($row = Database::Read($cursor))
214 { 214 {
215 $record = new $thisObjectName(); 215 $record = new $thisObjectName();
216 $record->recordId = $row['recordid']; 216 $record->recordId = $row['recordid'];
217 $record->userId = $row['userid']; 217 $record->userId = $row['userid'];
218 $record->reference = $this->Unescape($row['reference']); 218 $record->reference = $this->Unescape($row['reference']);
219 $record->data = $this->Unescape($row['data']); 219 $record->data = $this->Unescape($row['data']);
220 $record->version = $this->Unescape($row['version']); 220 $record->version = $this->Unescape($row['version']);
221 $record->creation_date = $row['creation_date']; 221 $record->creation_date = $row['creation_date'];
222 $oDate = strtotime($row['update_date']); 222 $oDate = strtotime($row['update_date']);
223 $record->update_date = date('r', $oDate); 223 $record->update_date = date('r', $oDate);
224 $record->access_date = $row['access_date']; 224 $record->access_date = $row['access_date'];
225 $recordList[] = $record; 225 $recordList[] = $record;
226 } 226 }
227 return $recordList; 227 return $recordList;
228 } 228 }
229 229
230 230
231 /** 231 /**
232 * Saves the object to the database 232 * Saves the object to the database
233 * @return integer $recordId 233 * @return integer $recordId
234 */ 234 */
235 function Save($deep = true) 235 function Save($deep = true)
236 { 236 {
237 $connection = Database::Connect(); 237 $connection = Database::Connect();
238 $this->update_date = date( 'r'); 238 $this->update_date = date( 'r');
239 $this->access_date = date( 'r'); 239 $this->access_date = date( 'r');
240 $this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1"; 240 $this->pog_query = "select `recordid` from `record` where `recordid`='".$this->recordId."' LIMIT 1";
241 $rows = Database::Query($this->pog_query, $connection); 241 $rows = Database::Query($this->pog_query, $connection);
242 if ($rows > 0) 242 if ($rows > 0)
243 { 243 {
244 $this->pog_query = "update `record` set 244 $this->pog_query = "update `record` set
245 `userid`='".$this->userId."', 245 `userid`='".$this->userId."',
246 `reference`='".$this->Escape($this->reference)."', 246 `reference`='".$this->Escape($this->reference)."',
247 `data`='".$this->Escape($this->data)."', 247 `data`='".$this->Escape($this->data)."',
248 `version`='".$this->Escape($this->version)."', 248 `version`='".$this->Escape($this->version)."',
249 `creation_date`='".$this->creation_date."', 249 `creation_date`='".$this->creation_date."',
250 `update_date`='".$this->update_date."', 250 `update_date`='".$this->update_date."',
251 `access_date`='".$this->access_date."' where `recordid`='".$this->recordId."'"; 251 `access_date`='".$this->access_date."' where `recordid`='".$this->recordId."'";
252 } 252 }
253 else 253 else
254 { 254 {
255 $this->pog_query = "insert into `record` (`userid`, `reference`, `data`, `version`, `creation_date`, `update_date`, `access_date` ) values ( 255 $this->pog_query = "insert into `record` (`userid`, `reference`, `data`, `version`, `creation_date`, `update_date`, `access_date` ) values (
256 '".$this->userId."', 256 '".$this->userId."',
257 '".$this->Escape($this->reference)."', 257 '".$this->Escape($this->reference)."',
258 '".$this->Escape($this->data)."', 258 '".$this->Escape($this->data)."',
259 '".$this->Escape($this->version)."', 259 '".$this->Escape($this->version)."',
260 '".$this->creation_date."', 260 '".$this->creation_date."',
261 '".$this->update_date."', 261 '".$this->update_date."',
262 '".$this->access_date."' )"; 262 '".$this->access_date."' )";
263 } 263 }
264 $insertId = Database::InsertOrUpdate($this->pog_query, $connection); 264 $insertId = Database::InsertOrUpdate($this->pog_query, $connection);
265 if ($this->recordId == "") 265 if ($this->recordId == "")
266 { 266 {
267 $this->recordId = $insertId; 267 $this->recordId = $insertId;
268 } 268 }
269 if ($deep) 269 if ($deep)
270 { 270 {
271 foreach ($this->_recordversionList as $recordversion) 271 foreach ($this->_recordversionList as $recordversion)
272 { 272 {
273 $recordversion->recordId = $this->recordId; 273 $recordversion->recordId = $this->recordId;
274 $recordversion->Save($deep); 274 $recordversion->Save($deep);
275 } 275 }
276 } 276 }
277 return $this->recordId; 277 return $this->recordId;
278 } 278 }
279 279
280 280
281 /** 281 /**
282 * Clones the object and saves it to the database 282 * Clones the object and saves it to the database
283 * @return integer $recordId 283 * @return integer $recordId
284 */ 284 */
285 function SaveNew($deep = false) 285 function SaveNew($deep = false)
286 { 286 {
287 $this->recordId = ''; 287 $this->recordId = '';
288 $this->creation_date = date( 'Y-m-d H:i:s'); 288 $this->creation_date = date( 'Y-m-d H:i:s');
289 return $this->Save($deep); 289 return $this->Save($deep);
290 } 290 }
291 291
292 292
293 /** 293 /**
294 * Deletes the object from the database 294 * Deletes the object from the database
295 * @return boolean 295 * @return boolean
296 */ 296 */
297 function Delete($deep = false, $across = false) 297 function Delete($deep = false, $across = false)
298 { 298 {
299 if ($deep) 299 if ($deep)
300 { 300 {
301 $recordversionList = $this->GetRecordversionList(); 301 $recordversionList = $this->GetRecordversionList();
302 foreach ($recordversionList as $recordversion) 302 foreach ($recordversionList as $recordversion)
303 { 303 {
304 $recordversion->Delete($deep, $across); 304 $recordversion->Delete($deep, $across);
305 } 305 }
306 } 306 }
307 $connection = Database::Connect(); 307 $connection = Database::Connect();
308 $this->pog_query = "delete from `record` where `recordid`='".$this->recordId."'"; 308 $this->pog_query = "delete from `record` where `recordid`='".$this->recordId."'";
309 return Database::NonQuery($this->pog_query, $connection); 309 return Database::NonQuery($this->pog_query, $connection);
310 } 310 }
311 311
312 312
313 /** 313 /**
314 * Deletes a list of objects that match given conditions 314 * Deletes a list of objects that match given conditions
315 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 315 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
316 * @param bool $deep 316 * @param bool $deep
317 * @return 317 * @return
318 */ 318 */
319 function DeleteList($fcv_array, $deep = false, $across = false) 319 function DeleteList($fcv_array, $deep = false, $across = false)
320 { 320 {
321 if (sizeof($fcv_array) > 0) 321 if (sizeof($fcv_array) > 0)
322 { 322 {
323 if ($deep || $across) 323 if ($deep || $across)
324 { 324 {
325 $objectList = $this->GetList($fcv_array); 325 $objectList = $this->GetList($fcv_array);
326 foreach ($objectList as $object) 326 foreach ($objectList as $object)
327 { 327 {
328 $object->Delete($deep, $across); 328 $object->Delete($deep, $across);
329 } 329 }
330 } 330 }
331 else 331 else
332 { 332 {
333 $connection = Database::Connect(); 333 $connection = Database::Connect();
334 $pog_query = "delete from `record` where "; 334 $pog_query = "delete from `record` where ";
335 for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) 335 for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++)
336 { 336 {
337 if (sizeof($fcv_array[$i]) == 1) 337 if (sizeof($fcv_array[$i]) == 1)
338 { 338 {
339 $pog_query .= " ".$fcv_array[$i][0]." "; 339 $pog_query .= " ".$fcv_array[$i][0]." ";
340 continue; 340 continue;
341 } 341 }
342 else 342 else
343 { 343 {
344 if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1) 344 if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1)
345 { 345 {
346 $pog_query .= " AND "; 346 $pog_query .= " AND ";
347 } 347 }
348 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') 348 if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET')
349 { 349 {
350 $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'"; 350 $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'";
351 } 351 }
352 else 352 else
353 { 353 {
354 $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'"; 354 $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'";
355 } 355 }
356 } 356 }
357 } 357 }
358 return Database::NonQuery($pog_query, $connection); 358 return Database::NonQuery($pog_query, $connection);
359 } 359 }
360 } 360 }
361 } 361 }
362 362
363 363
364 /** 364 /**
365 * Associates the user object to this one 365 * Associates the user object to this one
366 * @return boolean 366 * @return boolean
367 */ 367 */
368 function GetUser() 368 function GetUser()
369 { 369 {
370 $user = new user(); 370 $user = new user();
371 return $user->Get($this->userId); 371 return $user->Get($this->userId);
372 } 372 }
373 373
374 374
375 /** 375 /**
376 * Associates the user object to this one 376 * Associates the user object to this one
377 * @return 377 * @return
378 */ 378 */
379 function SetUser(&$user) 379 function SetUser(&$user)
380 { 380 {
381 $this->userId = $user->userId; 381 $this->userId = $user->userId;
382 } 382 }
383 383
384 384
385 /** 385 /**
386 * Gets a list of recordversion objects associated to this one 386 * Gets a list of recordversion objects associated to this one
387 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} 387 * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...}
388 * @param string $sortBy 388 * @param string $sortBy
389 * @param boolean $ascending 389 * @param boolean $ascending
390 * @param int limit 390 * @param int limit
391 * @return array of recordversion objects 391 * @return array of recordversion objects
392 */ 392 */
393 function GetRecordversionList($fcv_array = array(), $sortBy='', $ascending=true, $limit='') 393 function GetRecordversionList($fcv_array = array(), $sortBy='', $ascending=true, $limit='')
394 { 394 {
395 $recordversion = new recordversion(); 395 $recordversion = new recordversion();
396 $fcv_array[] = array("recordId", "=", $this->recordId); 396 $fcv_array[] = array("recordId", "=", $this->recordId);
397 $dbObjects = $recordversion->GetList($fcv_array, $sortBy, $ascending, $limit); 397 $dbObjects = $recordversion->GetList($fcv_array, $sortBy, $ascending, $limit);
398 return $dbObjects; 398 return $dbObjects;
399 } 399 }
400 400
401 401
402 /** 402 /**
403 * Makes this the parent of all recordversion objects in the recordversion List array. Any existing recordversion will become orphan(s) 403 * Makes this the parent of all recordversion objects in the recordversion List array. Any existing recordversion will become orphan(s)
404 * @return null 404 * @return null
405 */ 405 */
406 function SetRecordversionList(&$list) 406 function SetRecordversionList(&$list)
407 { 407 {
408 $this->_recordversionList = array(); 408 $this->_recordversionList = array();
409 $existingRecordversionList = $this->GetRecordversionList(); 409 $existingRecordversionList = $this->GetRecordversionList();
410 foreach ($existingRecordversionList as $recordversion) 410 foreach ($existingRecordversionList as $recordversion)
411 { 411 {
412 $recordversion->recordId = ''; 412 $recordversion->recordId = '';
413 $recordversion->Save(false); 413 $recordversion->Save(false);
414 } 414 }
415 $this->_recordversionList = $list; 415 $this->_recordversionList = $list;
416 } 416 }
417 417
418 418
419 /** 419 /**
420 * Associates the recordversion object to this one 420 * Associates the recordversion object to this one
421 * @return 421 * @return
422 */ 422 */
423 function AddRecordversion(&$recordversion) 423 function AddRecordversion(&$recordversion)
424 { 424 {
425 $recordversion->recordId = $this->recordId; 425 $recordversion->recordId = $this->recordId;
426 $found = false; 426 $found = false;
427 foreach($this->_recordversionList as $recordversion2) 427 foreach($this->_recordversionList as $recordversion2)
428 { 428 {
429 if ($recordversion->recordversionId > 0 && $recordversion->recordversionId == $recordversion2->recordversionId) 429 if ($recordversion->recordversionId > 0 && $recordversion->recordversionId == $recordversion2->recordversionId)
430 { 430 {
431 $found = true; 431 $found = true;
432 break; 432 break;
433 } 433 }
434 } 434 }
435 if (!$found) 435 if (!$found)
436 { 436 {
437 $this->_recordversionList[] = $recordversion; 437 $this->_recordversionList[] = $recordversion;
438 } 438 }
439 } 439 }
440} 440}
441?> 441?>