1 | <?php |
---|
2 | |
---|
3 | |
---|
4 | abstract class BaseTblspaceresource extends BaseObject implements Persistent { |
---|
5 | |
---|
6 | |
---|
7 | |
---|
8 | protected static $peer; |
---|
9 | |
---|
10 | |
---|
11 | protected $res_id; |
---|
12 | |
---|
13 | |
---|
14 | protected $res_filename; |
---|
15 | |
---|
16 | |
---|
17 | protected $res_filesize; |
---|
18 | |
---|
19 | |
---|
20 | protected $res_filecrc; |
---|
21 | |
---|
22 | |
---|
23 | protected $collTblspacefiles; |
---|
24 | |
---|
25 | |
---|
26 | private $lastTblspacefileCriteria = null; |
---|
27 | |
---|
28 | |
---|
29 | protected $alreadyInSave = false; |
---|
30 | |
---|
31 | |
---|
32 | protected $alreadyInValidation = false; |
---|
33 | |
---|
34 | |
---|
35 | public function __construct() |
---|
36 | { |
---|
37 | parent::__construct(); |
---|
38 | $this->applyDefaultValues(); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | public function applyDefaultValues() |
---|
43 | { |
---|
44 | } |
---|
45 | |
---|
46 | |
---|
47 | public function getResId() |
---|
48 | { |
---|
49 | return $this->res_id; |
---|
50 | } |
---|
51 | |
---|
52 | |
---|
53 | public function getResFilename() |
---|
54 | { |
---|
55 | return $this->res_filename; |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | public function getResFilesize() |
---|
60 | { |
---|
61 | return $this->res_filesize; |
---|
62 | } |
---|
63 | |
---|
64 | |
---|
65 | public function getResFilecrc() |
---|
66 | { |
---|
67 | return $this->res_filecrc; |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | public function setResId($v) |
---|
72 | { |
---|
73 | if ($v !== null) { |
---|
74 | $v = (int) $v; |
---|
75 | } |
---|
76 | |
---|
77 | if ($this->res_id !== $v) { |
---|
78 | $this->res_id = $v; |
---|
79 | $this->modifiedColumns[] = TblspaceresourcePeer::RES_ID; |
---|
80 | } |
---|
81 | |
---|
82 | return $this; |
---|
83 | } |
---|
84 | |
---|
85 | public function setResFilename($v) |
---|
86 | { |
---|
87 | if ($v !== null) { |
---|
88 | $v = (string) $v; |
---|
89 | } |
---|
90 | |
---|
91 | if ($this->res_filename !== $v) { |
---|
92 | $this->res_filename = $v; |
---|
93 | $this->modifiedColumns[] = TblspaceresourcePeer::RES_FILENAME; |
---|
94 | } |
---|
95 | |
---|
96 | return $this; |
---|
97 | } |
---|
98 | |
---|
99 | public function setResFilesize($v) |
---|
100 | { |
---|
101 | if ($v !== null) { |
---|
102 | $v = (int) $v; |
---|
103 | } |
---|
104 | |
---|
105 | if ($this->res_filesize !== $v) { |
---|
106 | $this->res_filesize = $v; |
---|
107 | $this->modifiedColumns[] = TblspaceresourcePeer::RES_FILESIZE; |
---|
108 | } |
---|
109 | |
---|
110 | return $this; |
---|
111 | } |
---|
112 | |
---|
113 | public function setResFilecrc($v) |
---|
114 | { |
---|
115 | if ($v !== null) { |
---|
116 | $v = (int) $v; |
---|
117 | } |
---|
118 | |
---|
119 | if ($this->res_filecrc !== $v) { |
---|
120 | $this->res_filecrc = $v; |
---|
121 | $this->modifiedColumns[] = TblspaceresourcePeer::RES_FILECRC; |
---|
122 | } |
---|
123 | |
---|
124 | return $this; |
---|
125 | } |
---|
126 | |
---|
127 | public function hasOnlyDefaultValues() |
---|
128 | { |
---|
129 | if (array_diff($this->modifiedColumns, array())) { |
---|
130 | return false; |
---|
131 | } |
---|
132 | |
---|
133 | return true; |
---|
134 | } |
---|
135 | |
---|
136 | public function hydrate($row, $startcol = 0, $rehydrate = false) |
---|
137 | { |
---|
138 | try { |
---|
139 | |
---|
140 | $this->res_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null; |
---|
141 | $this->res_filename = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null; |
---|
142 | $this->res_filesize = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null; |
---|
143 | $this->res_filecrc = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null; |
---|
144 | $this->resetModified(); |
---|
145 | |
---|
146 | $this->setNew(false); |
---|
147 | |
---|
148 | if ($rehydrate) { |
---|
149 | $this->ensureConsistency(); |
---|
150 | } |
---|
151 | |
---|
152 | return $startcol + 4; |
---|
153 | } catch (Exception $e) { |
---|
154 | throw new PropelException("Error populating Tblspaceresource object", $e); |
---|
155 | } |
---|
156 | } |
---|
157 | |
---|
158 | |
---|
159 | public function ensureConsistency() |
---|
160 | { |
---|
161 | |
---|
162 | } |
---|
163 | |
---|
164 | public function reload($deep = false, PropelPDO $con = null) |
---|
165 | { |
---|
166 | if ($this->isDeleted()) { |
---|
167 | throw new PropelException("Cannot reload a deleted object."); |
---|
168 | } |
---|
169 | |
---|
170 | if ($this->isNew()) { |
---|
171 | throw new PropelException("Cannot reload an unsaved object."); |
---|
172 | } |
---|
173 | |
---|
174 | if ($con === null) { |
---|
175 | $con = Propel::getConnection(TblspaceresourcePeer::DATABASE_NAME, Propel::CONNECTION_READ); |
---|
176 | } |
---|
177 | |
---|
178 | |
---|
179 | $stmt = TblspaceresourcePeer::doSelectStmt($this->buildPkeyCriteria(), $con); |
---|
180 | $row = $stmt->fetch(PDO::FETCH_NUM); |
---|
181 | $stmt->closeCursor(); |
---|
182 | if (!$row) { |
---|
183 | throw new PropelException('Cannot find matching row in the database to reload object values.'); |
---|
184 | } |
---|
185 | $this->hydrate($row, 0, true); |
---|
186 | if ($deep) { |
---|
187 | $this->collTblspacefiles = null; |
---|
188 | $this->lastTblspacefileCriteria = null; |
---|
189 | |
---|
190 | } } |
---|
191 | |
---|
192 | |
---|
193 | public function delete(PropelPDO $con = null) |
---|
194 | { |
---|
195 | if ($this->isDeleted()) { |
---|
196 | throw new PropelException("This object has already been deleted."); |
---|
197 | } |
---|
198 | |
---|
199 | if ($con === null) { |
---|
200 | $con = Propel::getConnection(TblspaceresourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
201 | } |
---|
202 | |
---|
203 | $con->beginTransaction(); |
---|
204 | try { |
---|
205 | TblspaceresourcePeer::doDelete($this, $con); |
---|
206 | $this->setDeleted(true); |
---|
207 | $con->commit(); |
---|
208 | } catch (PropelException $e) { |
---|
209 | $con->rollBack(); |
---|
210 | throw $e; |
---|
211 | } |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | public function save(PropelPDO $con = null) |
---|
216 | { |
---|
217 | if ($this->isDeleted()) { |
---|
218 | throw new PropelException("You cannot save an object that has been deleted."); |
---|
219 | } |
---|
220 | |
---|
221 | if ($con === null) { |
---|
222 | $con = Propel::getConnection(TblspaceresourcePeer::DATABASE_NAME, Propel::CONNECTION_WRITE); |
---|
223 | } |
---|
224 | |
---|
225 | $con->beginTransaction(); |
---|
226 | try { |
---|
227 | $affectedRows = $this->doSave($con); |
---|
228 | $con->commit(); |
---|
229 | TblspaceresourcePeer::addInstanceToPool($this); |
---|
230 | return $affectedRows; |
---|
231 | } catch (PropelException $e) { |
---|
232 | $con->rollBack(); |
---|
233 | throw $e; |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | |
---|
238 | protected function doSave(PropelPDO $con) |
---|
239 | { |
---|
240 | $affectedRows = 0; if (!$this->alreadyInSave) { |
---|
241 | $this->alreadyInSave = true; |
---|
242 | |
---|
243 | if ($this->isNew() ) { |
---|
244 | $this->modifiedColumns[] = TblspaceresourcePeer::RES_ID; |
---|
245 | } |
---|
246 | |
---|
247 | if ($this->isModified()) { |
---|
248 | if ($this->isNew()) { |
---|
249 | $pk = TblspaceresourcePeer::doInsert($this, $con); |
---|
250 | $affectedRows += 1; |
---|
251 | $this->setResId($pk); |
---|
252 | $this->setNew(false); |
---|
253 | } else { |
---|
254 | $affectedRows += TblspaceresourcePeer::doUpdate($this, $con); |
---|
255 | } |
---|
256 | |
---|
257 | $this->resetModified(); } |
---|
258 | |
---|
259 | if ($this->collTblspacefiles !== null) { |
---|
260 | foreach ($this->collTblspacefiles as $referrerFK) { |
---|
261 | if (!$referrerFK->isDeleted()) { |
---|
262 | $affectedRows += $referrerFK->save($con); |
---|
263 | } |
---|
264 | } |
---|
265 | } |
---|
266 | |
---|
267 | $this->alreadyInSave = false; |
---|
268 | |
---|
269 | } |
---|
270 | return $affectedRows; |
---|
271 | } |
---|
272 | |
---|
273 | protected $validationFailures = array(); |
---|
274 | |
---|
275 | |
---|
276 | public function getValidationFailures() |
---|
277 | { |
---|
278 | return $this->validationFailures; |
---|
279 | } |
---|
280 | |
---|
281 | |
---|
282 | public function validate($columns = null) |
---|
283 | { |
---|
284 | $res = $this->doValidate($columns); |
---|
285 | if ($res === true) { |
---|
286 | $this->validationFailures = array(); |
---|
287 | return true; |
---|
288 | } else { |
---|
289 | $this->validationFailures = $res; |
---|
290 | return false; |
---|
291 | } |
---|
292 | } |
---|
293 | |
---|
294 | |
---|
295 | protected function doValidate($columns = null) |
---|
296 | { |
---|
297 | if (!$this->alreadyInValidation) { |
---|
298 | $this->alreadyInValidation = true; |
---|
299 | $retval = null; |
---|
300 | |
---|
301 | $failureMap = array(); |
---|
302 | |
---|
303 | |
---|
304 | if (($retval = TblspaceresourcePeer::doValidate($this, $columns)) !== true) { |
---|
305 | $failureMap = array_merge($failureMap, $retval); |
---|
306 | } |
---|
307 | |
---|
308 | |
---|
309 | if ($this->collTblspacefiles !== null) { |
---|
310 | foreach ($this->collTblspacefiles as $referrerFK) { |
---|
311 | if (!$referrerFK->validate($columns)) { |
---|
312 | $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures()); |
---|
313 | } |
---|
314 | } |
---|
315 | } |
---|
316 | |
---|
317 | |
---|
318 | $this->alreadyInValidation = false; |
---|
319 | } |
---|
320 | |
---|
321 | return (!empty($failureMap) ? $failureMap : true); |
---|
322 | } |
---|
323 | |
---|
324 | |
---|
325 | public function getByName($name, $type = BasePeer::TYPE_PHPNAME) |
---|
326 | { |
---|
327 | $pos = TblspaceresourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); |
---|
328 | $field = $this->getByPosition($pos); |
---|
329 | return $field; |
---|
330 | } |
---|
331 | |
---|
332 | |
---|
333 | public function getByPosition($pos) |
---|
334 | { |
---|
335 | switch($pos) { |
---|
336 | case 0: |
---|
337 | return $this->getResId(); |
---|
338 | break; |
---|
339 | case 1: |
---|
340 | return $this->getResFilename(); |
---|
341 | break; |
---|
342 | case 2: |
---|
343 | return $this->getResFilesize(); |
---|
344 | break; |
---|
345 | case 3: |
---|
346 | return $this->getResFilecrc(); |
---|
347 | break; |
---|
348 | default: |
---|
349 | return null; |
---|
350 | break; |
---|
351 | } } |
---|
352 | |
---|
353 | |
---|
354 | public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true) |
---|
355 | { |
---|
356 | $keys = TblspaceresourcePeer::getFieldNames($keyType); |
---|
357 | $result = array( |
---|
358 | $keys[0] => $this->getResId(), |
---|
359 | $keys[1] => $this->getResFilename(), |
---|
360 | $keys[2] => $this->getResFilesize(), |
---|
361 | $keys[3] => $this->getResFilecrc(), |
---|
362 | ); |
---|
363 | return $result; |
---|
364 | } |
---|
365 | |
---|
366 | |
---|
367 | public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME) |
---|
368 | { |
---|
369 | $pos = TblspaceresourcePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM); |
---|
370 | return $this->setByPosition($pos, $value); |
---|
371 | } |
---|
372 | |
---|
373 | |
---|
374 | public function setByPosition($pos, $value) |
---|
375 | { |
---|
376 | switch($pos) { |
---|
377 | case 0: |
---|
378 | $this->setResId($value); |
---|
379 | break; |
---|
380 | case 1: |
---|
381 | $this->setResFilename($value); |
---|
382 | break; |
---|
383 | case 2: |
---|
384 | $this->setResFilesize($value); |
---|
385 | break; |
---|
386 | case 3: |
---|
387 | $this->setResFilecrc($value); |
---|
388 | break; |
---|
389 | } } |
---|
390 | |
---|
391 | |
---|
392 | public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) |
---|
393 | { |
---|
394 | $keys = TblspaceresourcePeer::getFieldNames($keyType); |
---|
395 | |
---|
396 | if (array_key_exists($keys[0], $arr)) $this->setResId($arr[$keys[0]]); |
---|
397 | if (array_key_exists($keys[1], $arr)) $this->setResFilename($arr[$keys[1]]); |
---|
398 | if (array_key_exists($keys[2], $arr)) $this->setResFilesize($arr[$keys[2]]); |
---|
399 | if (array_key_exists($keys[3], $arr)) $this->setResFilecrc($arr[$keys[3]]); |
---|
400 | } |
---|
401 | |
---|
402 | |
---|
403 | public function buildCriteria() |
---|
404 | { |
---|
405 | $criteria = new Criteria(TblspaceresourcePeer::DATABASE_NAME); |
---|
406 | |
---|
407 | if ($this->isColumnModified(TblspaceresourcePeer::RES_ID)) $criteria->add(TblspaceresourcePeer::RES_ID, $this->res_id); |
---|
408 | if ($this->isColumnModified(TblspaceresourcePeer::RES_FILENAME)) $criteria->add(TblspaceresourcePeer::RES_FILENAME, $this->res_filename); |
---|
409 | if ($this->isColumnModified(TblspaceresourcePeer::RES_FILESIZE)) $criteria->add(TblspaceresourcePeer::RES_FILESIZE, $this->res_filesize); |
---|
410 | if ($this->isColumnModified(TblspaceresourcePeer::RES_FILECRC)) $criteria->add(TblspaceresourcePeer::RES_FILECRC, $this->res_filecrc); |
---|
411 | |
---|
412 | return $criteria; |
---|
413 | } |
---|
414 | |
---|
415 | |
---|
416 | public function buildPkeyCriteria() |
---|
417 | { |
---|
418 | $criteria = new Criteria(TblspaceresourcePeer::DATABASE_NAME); |
---|
419 | |
---|
420 | $criteria->add(TblspaceresourcePeer::RES_ID, $this->res_id); |
---|
421 | |
---|
422 | return $criteria; |
---|
423 | } |
---|
424 | |
---|
425 | |
---|
426 | public function getPrimaryKey() |
---|
427 | { |
---|
428 | return $this->getResId(); |
---|
429 | } |
---|
430 | |
---|
431 | |
---|
432 | public function setPrimaryKey($key) |
---|
433 | { |
---|
434 | $this->setResId($key); |
---|
435 | } |
---|
436 | |
---|
437 | |
---|
438 | public function copyInto($copyObj, $deepCopy = false) |
---|
439 | { |
---|
440 | |
---|
441 | $copyObj->setResFilename($this->res_filename); |
---|
442 | |
---|
443 | $copyObj->setResFilesize($this->res_filesize); |
---|
444 | |
---|
445 | $copyObj->setResFilecrc($this->res_filecrc); |
---|
446 | |
---|
447 | |
---|
448 | if ($deepCopy) { |
---|
449 | $copyObj->setNew(false); |
---|
450 | |
---|
451 | foreach ($this->getTblspacefiles() as $relObj) { |
---|
452 | if ($relObj !== $this) { $copyObj->addTblspacefile($relObj->copy($deepCopy)); |
---|
453 | } |
---|
454 | } |
---|
455 | |
---|
456 | } |
---|
457 | |
---|
458 | $copyObj->setNew(true); |
---|
459 | |
---|
460 | $copyObj->setResId(NULL); |
---|
461 | } |
---|
462 | |
---|
463 | |
---|
464 | public function copy($deepCopy = false) |
---|
465 | { |
---|
466 | $clazz = get_class($this); |
---|
467 | $copyObj = new $clazz(); |
---|
468 | $this->copyInto($copyObj, $deepCopy); |
---|
469 | return $copyObj; |
---|
470 | } |
---|
471 | |
---|
472 | |
---|
473 | public function getPeer() |
---|
474 | { |
---|
475 | if (self::$peer === null) { |
---|
476 | self::$peer = new TblspaceresourcePeer(); |
---|
477 | } |
---|
478 | return self::$peer; |
---|
479 | } |
---|
480 | |
---|
481 | |
---|
482 | public function clearTblspacefiles() |
---|
483 | { |
---|
484 | $this->collTblspacefiles = null; } |
---|
485 | |
---|
486 | |
---|
487 | public function initTblspacefiles() |
---|
488 | { |
---|
489 | $this->collTblspacefiles = array(); |
---|
490 | } |
---|
491 | |
---|
492 | |
---|
493 | public function getTblspacefiles($criteria = null, PropelPDO $con = null) |
---|
494 | { |
---|
495 | if ($criteria === null) { |
---|
496 | $criteria = new Criteria(TblspaceresourcePeer::DATABASE_NAME); |
---|
497 | } |
---|
498 | elseif ($criteria instanceof Criteria) |
---|
499 | { |
---|
500 | $criteria = clone $criteria; |
---|
501 | } |
---|
502 | |
---|
503 | if ($this->collTblspacefiles === null) { |
---|
504 | if ($this->isNew()) { |
---|
505 | $this->collTblspacefiles = array(); |
---|
506 | } else { |
---|
507 | |
---|
508 | $criteria->add(TblspacefilePeer::FILE_RESOURCE, $this->res_id); |
---|
509 | |
---|
510 | TblspacefilePeer::addSelectColumns($criteria); |
---|
511 | $this->collTblspacefiles = TblspacefilePeer::doSelect($criteria, $con); |
---|
512 | } |
---|
513 | } else { |
---|
514 | if (!$this->isNew()) { |
---|
515 | |
---|
516 | |
---|
517 | $criteria->add(TblspacefilePeer::FILE_RESOURCE, $this->res_id); |
---|
518 | |
---|
519 | TblspacefilePeer::addSelectColumns($criteria); |
---|
520 | if (!isset($this->lastTblspacefileCriteria) || !$this->lastTblspacefileCriteria->equals($criteria)) { |
---|
521 | $this->collTblspacefiles = TblspacefilePeer::doSelect($criteria, $con); |
---|
522 | } |
---|
523 | } |
---|
524 | } |
---|
525 | $this->lastTblspacefileCriteria = $criteria; |
---|
526 | return $this->collTblspacefiles; |
---|
527 | } |
---|
528 | |
---|
529 | |
---|
530 | public function countTblspacefiles(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) |
---|
531 | { |
---|
532 | if ($criteria === null) { |
---|
533 | $criteria = new Criteria(TblspaceresourcePeer::DATABASE_NAME); |
---|
534 | } else { |
---|
535 | $criteria = clone $criteria; |
---|
536 | } |
---|
537 | |
---|
538 | if ($distinct) { |
---|
539 | $criteria->setDistinct(); |
---|
540 | } |
---|
541 | |
---|
542 | $count = null; |
---|
543 | |
---|
544 | if ($this->collTblspacefiles === null) { |
---|
545 | if ($this->isNew()) { |
---|
546 | $count = 0; |
---|
547 | } else { |
---|
548 | |
---|
549 | $criteria->add(TblspacefilePeer::FILE_RESOURCE, $this->res_id); |
---|
550 | |
---|
551 | $count = TblspacefilePeer::doCount($criteria, $con); |
---|
552 | } |
---|
553 | } else { |
---|
554 | if (!$this->isNew()) { |
---|
555 | |
---|
556 | |
---|
557 | $criteria->add(TblspacefilePeer::FILE_RESOURCE, $this->res_id); |
---|
558 | |
---|
559 | if (!isset($this->lastTblspacefileCriteria) || !$this->lastTblspacefileCriteria->equals($criteria)) { |
---|
560 | $count = TblspacefilePeer::doCount($criteria, $con); |
---|
561 | } else { |
---|
562 | $count = count($this->collTblspacefiles); |
---|
563 | } |
---|
564 | } else { |
---|
565 | $count = count($this->collTblspacefiles); |
---|
566 | } |
---|
567 | } |
---|
568 | $this->lastTblspacefileCriteria = $criteria; |
---|
569 | return $count; |
---|
570 | } |
---|
571 | |
---|
572 | |
---|
573 | public function addTblspacefile(Tblspacefile $l) |
---|
574 | { |
---|
575 | if ($this->collTblspacefiles === null) { |
---|
576 | $this->initTblspacefiles(); |
---|
577 | } |
---|
578 | if (!in_array($l, $this->collTblspacefiles, true)) { array_push($this->collTblspacefiles, $l); |
---|
579 | $l->setTblspaceresource($this); |
---|
580 | } |
---|
581 | } |
---|
582 | |
---|
583 | |
---|
584 | public function clearAllReferences($deep = false) |
---|
585 | { |
---|
586 | if ($deep) { |
---|
587 | if ($this->collTblspacefiles) { |
---|
588 | foreach ((array) $this->collTblspacefiles as $o) { |
---|
589 | $o->clearAllReferences($deep); |
---|
590 | } |
---|
591 | } |
---|
592 | } |
---|
593 | $this->collTblspacefiles = null; |
---|
594 | } |
---|
595 | |
---|
596 | } |
---|