source: pro-bachkim-filespace/sourcecode/api.violet.vn/lib/model/om/BaseTblspacecategory.php @ 19

Last change on this file since 19 was 19, checked in by dungnv, 11 years ago
File size: 10.9 KB
Line 
1<?php
2
3
4abstract class BaseTblspacecategory extends BaseObject  implements Persistent {
5
6
7       
8        protected static $peer;
9
10       
11        protected $cat_id;
12
13       
14        protected $cat_name;
15
16       
17        protected $cat_parent;
18
19       
20        protected $cat_user;
21
22       
23        protected $cat_date;
24
25       
26        protected $alreadyInSave = false;
27
28       
29        protected $alreadyInValidation = false;
30
31       
32        public function __construct()
33        {
34                parent::__construct();
35                $this->applyDefaultValues();
36        }
37
38       
39        public function applyDefaultValues()
40        {
41        }
42
43       
44        public function getCatId()
45        {
46                return $this->cat_id;
47        }
48
49       
50        public function getCatName()
51        {
52                return $this->cat_name;
53        }
54
55       
56        public function getCatParent()
57        {
58                return $this->cat_parent;
59        }
60
61       
62        public function getCatUser()
63        {
64                return $this->cat_user;
65        }
66
67       
68        public function getCatDate($format = 'Y-m-d H:i:s')
69        {
70                if ($this->cat_date === null) {
71                        return null;
72                }
73
74
75                if ($this->cat_date === '0000-00-00 00:00:00') {
76                                                                        return null;
77                } else {
78                        try {
79                                $dt = new DateTime($this->cat_date);
80                        } catch (Exception $x) {
81                                throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->cat_date, true), $x);
82                        }
83                }
84
85                if ($format === null) {
86                                                return $dt;
87                } elseif (strpos($format, '%') !== false) {
88                        return strftime($format, $dt->format('U'));
89                } else {
90                        return $dt->format($format);
91                }
92        }
93
94       
95        public function setCatId($v)
96        {
97                if ($v !== null) {
98                        $v = (int) $v;
99                }
100
101                if ($this->cat_id !== $v) {
102                        $this->cat_id = $v;
103                        $this->modifiedColumns[] = TblspacecategoryPeer::CAT_ID;
104                }
105
106                return $this;
107        }
108       
109        public function setCatName($v)
110        {
111                if ($v !== null) {
112                        $v = (string) $v;
113                }
114
115                if ($this->cat_name !== $v) {
116                        $this->cat_name = $v;
117                        $this->modifiedColumns[] = TblspacecategoryPeer::CAT_NAME;
118                }
119
120                return $this;
121        }
122       
123        public function setCatParent($v)
124        {
125                if ($v !== null) {
126                        $v = (int) $v;
127                }
128
129                if ($this->cat_parent !== $v) {
130                        $this->cat_parent = $v;
131                        $this->modifiedColumns[] = TblspacecategoryPeer::CAT_PARENT;
132                }
133
134                return $this;
135        }
136       
137        public function setCatUser($v)
138        {
139                if ($v !== null) {
140                        $v = (int) $v;
141                }
142
143                if ($this->cat_user !== $v) {
144                        $this->cat_user = $v;
145                        $this->modifiedColumns[] = TblspacecategoryPeer::CAT_USER;
146                }
147
148                return $this;
149        }
150       
151        public function setCatDate($v)
152        {
153                                                if ($v === null || $v === '') {
154                        $dt = null;
155                } elseif ($v instanceof DateTime) {
156                        $dt = $v;
157                } else {
158                                                                        try {
159                                if (is_numeric($v)) {                                   $dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
160                                                                                                                        $dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
161                                } else {
162                                        $dt = new DateTime($v);
163                                }
164                        } catch (Exception $x) {
165                                throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
166                        }
167                }
168
169                if ( $this->cat_date !== null || $dt !== null ) {
170                       
171                        $currNorm = ($this->cat_date !== null && $tmpDt = new DateTime($this->cat_date)) ? $tmpDt->format('Y-m-d H:i:s') : null;
172                        $newNorm = ($dt !== null) ? $dt->format('Y-m-d H:i:s') : null;
173
174                        if ( ($currNorm !== $newNorm)                                   )
175                        {
176                                $this->cat_date = ($dt ? $dt->format('Y-m-d H:i:s') : null);
177                                $this->modifiedColumns[] = TblspacecategoryPeer::CAT_DATE;
178                        }
179                }
180                return $this;
181        }
182       
183        public function hasOnlyDefaultValues()
184        {
185                                                if (array_diff($this->modifiedColumns, array())) {
186                                return false;
187                        }
188
189                                return true;
190        }
191       
192        public function hydrate($row, $startcol = 0, $rehydrate = false)
193        {
194                try {
195
196                        $this->cat_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
197                        $this->cat_name = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
198                        $this->cat_parent = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
199                        $this->cat_user = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
200                        $this->cat_date = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
201                        $this->resetModified();
202
203                        $this->setNew(false);
204
205                        if ($rehydrate) {
206                                $this->ensureConsistency();
207                        }
208
209                                                return $startcol + 5;
210                } catch (Exception $e) {
211                        throw new PropelException("Error populating Tblspacecategory object", $e);
212                }
213        }
214
215       
216        public function ensureConsistency()
217        {
218
219        }
220       
221        public function reload($deep = false, PropelPDO $con = null)
222        {
223                if ($this->isDeleted()) {
224                        throw new PropelException("Cannot reload a deleted object.");
225                }
226
227                if ($this->isNew()) {
228                        throw new PropelException("Cannot reload an unsaved object.");
229                }
230
231                if ($con === null) {
232                        $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
233                }
234
235                               
236                $stmt = TblspacecategoryPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
237                $row = $stmt->fetch(PDO::FETCH_NUM);
238                $stmt->closeCursor();
239                if (!$row) {
240                        throw new PropelException('Cannot find matching row in the database to reload object values.');
241                }
242                $this->hydrate($row, 0, true);
243                if ($deep) { 
244                }       }
245
246       
247        public function delete(PropelPDO $con = null)
248        {
249                if ($this->isDeleted()) {
250                        throw new PropelException("This object has already been deleted.");
251                }
252
253                if ($con === null) {
254                        $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
255                }
256               
257                $con->beginTransaction();
258                try {
259                        TblspacecategoryPeer::doDelete($this, $con);
260                        $this->setDeleted(true);
261                        $con->commit();
262                } catch (PropelException $e) {
263                        $con->rollBack();
264                        throw $e;
265                }
266        }
267
268       
269        public function save(PropelPDO $con = null)
270        {
271                if ($this->isDeleted()) {
272                        throw new PropelException("You cannot save an object that has been deleted.");
273                }
274
275                if ($con === null) {
276                        $con = Propel::getConnection(TblspacecategoryPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
277                }
278               
279                $con->beginTransaction();
280                try {
281                        $affectedRows = $this->doSave($con);
282                        $con->commit();
283                        TblspacecategoryPeer::addInstanceToPool($this);
284                        return $affectedRows;
285                } catch (PropelException $e) {
286                        $con->rollBack();
287                        throw $e;
288                }
289        }
290
291       
292        protected function doSave(PropelPDO $con)
293        {
294                $affectedRows = 0;              if (!$this->alreadyInSave) {
295                        $this->alreadyInSave = true;
296
297                        if ($this->isNew() ) {
298                                $this->modifiedColumns[] = TblspacecategoryPeer::CAT_ID;
299                        }
300
301                                                if ($this->isModified()) {
302                                if ($this->isNew()) {
303                                        $pk = TblspacecategoryPeer::doInsert($this, $con);
304                                        $affectedRows += 1;                                                                                                                                                             
305                                        $this->setCatId($pk); 
306                                        $this->setNew(false);
307                                } else {
308                                        $affectedRows += TblspacecategoryPeer::doUpdate($this, $con);
309                                }
310
311                                $this->resetModified();                         }
312
313                        $this->alreadyInSave = false;
314
315                }
316                return $affectedRows;
317        }
318       
319        protected $validationFailures = array();
320
321       
322        public function getValidationFailures()
323        {
324                return $this->validationFailures;
325        }
326
327       
328        public function validate($columns = null)
329        {
330                $res = $this->doValidate($columns);
331                if ($res === true) {
332                        $this->validationFailures = array();
333                        return true;
334                } else {
335                        $this->validationFailures = $res;
336                        return false;
337                }
338        }
339
340       
341        protected function doValidate($columns = null)
342        {
343                if (!$this->alreadyInValidation) {
344                        $this->alreadyInValidation = true;
345                        $retval = null;
346
347                        $failureMap = array();
348
349
350                        if (($retval = TblspacecategoryPeer::doValidate($this, $columns)) !== true) {
351                                $failureMap = array_merge($failureMap, $retval);
352                        }
353
354
355
356                        $this->alreadyInValidation = false;
357                }
358
359                return (!empty($failureMap) ? $failureMap : true);
360        }
361
362       
363        public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
364        {
365                $pos = TblspacecategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
366                $field = $this->getByPosition($pos);
367                return $field;
368        }
369
370       
371        public function getByPosition($pos)
372        {
373                switch($pos) {
374                        case 0:
375                                return $this->getCatId();
376                                break;
377                        case 1:
378                                return $this->getCatName();
379                                break;
380                        case 2:
381                                return $this->getCatParent();
382                                break;
383                        case 3:
384                                return $this->getCatUser();
385                                break;
386                        case 4:
387                                return $this->getCatDate();
388                                break;
389                        default:
390                                return null;
391                                break;
392                }       }
393
394       
395        public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
396        {
397                $keys = TblspacecategoryPeer::getFieldNames($keyType);
398                $result = array(
399                        $keys[0] => $this->getCatId(),
400                        $keys[1] => $this->getCatName(),
401                        $keys[2] => $this->getCatParent(),
402                        $keys[3] => $this->getCatUser(),
403                        $keys[4] => $this->getCatDate(),
404                );
405                return $result;
406        }
407
408       
409        public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
410        {
411                $pos = TblspacecategoryPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
412                return $this->setByPosition($pos, $value);
413        }
414
415       
416        public function setByPosition($pos, $value)
417        {
418                switch($pos) {
419                        case 0:
420                                $this->setCatId($value);
421                                break;
422                        case 1:
423                                $this->setCatName($value);
424                                break;
425                        case 2:
426                                $this->setCatParent($value);
427                                break;
428                        case 3:
429                                $this->setCatUser($value);
430                                break;
431                        case 4:
432                                $this->setCatDate($value);
433                                break;
434                }       }
435
436       
437        public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
438        {
439                $keys = TblspacecategoryPeer::getFieldNames($keyType);
440
441                if (array_key_exists($keys[0], $arr)) $this->setCatId($arr[$keys[0]]);
442                if (array_key_exists($keys[1], $arr)) $this->setCatName($arr[$keys[1]]);
443                if (array_key_exists($keys[2], $arr)) $this->setCatParent($arr[$keys[2]]);
444                if (array_key_exists($keys[3], $arr)) $this->setCatUser($arr[$keys[3]]);
445                if (array_key_exists($keys[4], $arr)) $this->setCatDate($arr[$keys[4]]);
446        }
447
448       
449        public function buildCriteria()
450        {
451                $criteria = new Criteria(TblspacecategoryPeer::DATABASE_NAME);
452
453                if ($this->isColumnModified(TblspacecategoryPeer::CAT_ID)) $criteria->add(TblspacecategoryPeer::CAT_ID, $this->cat_id);
454                if ($this->isColumnModified(TblspacecategoryPeer::CAT_NAME)) $criteria->add(TblspacecategoryPeer::CAT_NAME, $this->cat_name);
455                if ($this->isColumnModified(TblspacecategoryPeer::CAT_PARENT)) $criteria->add(TblspacecategoryPeer::CAT_PARENT, $this->cat_parent);
456                if ($this->isColumnModified(TblspacecategoryPeer::CAT_USER)) $criteria->add(TblspacecategoryPeer::CAT_USER, $this->cat_user);
457                if ($this->isColumnModified(TblspacecategoryPeer::CAT_DATE)) $criteria->add(TblspacecategoryPeer::CAT_DATE, $this->cat_date);
458
459                return $criteria;
460        }
461
462       
463        public function buildPkeyCriteria()
464        {
465                $criteria = new Criteria(TblspacecategoryPeer::DATABASE_NAME);
466
467                $criteria->add(TblspacecategoryPeer::CAT_ID, $this->cat_id);
468
469                return $criteria;
470        }
471
472       
473        public function getPrimaryKey()
474        {
475                return $this->getCatId();
476        }
477
478       
479        public function setPrimaryKey($key)
480        {
481                $this->setCatId($key);
482        }
483
484       
485        public function copyInto($copyObj, $deepCopy = false)
486        {
487
488                $copyObj->setCatName($this->cat_name);
489
490                $copyObj->setCatParent($this->cat_parent);
491
492                $copyObj->setCatUser($this->cat_user);
493
494                $copyObj->setCatDate($this->cat_date);
495
496
497                $copyObj->setNew(true);
498
499                $copyObj->setCatId(NULL);
500        }
501
502       
503        public function copy($deepCopy = false)
504        {
505                                $clazz = get_class($this);
506                $copyObj = new $clazz();
507                $this->copyInto($copyObj, $deepCopy);
508                return $copyObj;
509        }
510
511       
512        public function getPeer()
513        {
514                if (self::$peer === null) {
515                        self::$peer = new TblspacecategoryPeer();
516                }
517                return self::$peer;
518        }
519
520       
521        public function clearAllReferences($deep = false)
522        {
523                if ($deep) {
524                }
525        }
526
527}
Note: See TracBrowser for help on using the repository browser.