MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
persistentmanager.class
Ir para a documentação deste ficheiro.
1<?php
2
4{
5 private $factory;
6 private $active = FALSE;
7 private $closed = FALSE;
8 private $dbConnections = array();
9
10 public function __construct(PersistentManagerFactory $factory)
11 {
12 $this->factory = $factory;
13 }
14
15 private function execute(MDatabase $db, $commands, $transaction = NULL)
16 {
17 $this->factory->miolo->ProfileEnter('PersistentManager::Execute');
18 if (!is_array($commands))
19 {
20 $commands = array($commands);
21 }
22 if ($newTransaction = is_null($transaction))
23 {
24 $transaction = $db->getTransaction();
25 }
26 foreach ($commands as $command)
27 {
28 $transaction->addCommand($command);
29 }
30 if ($newTransaction)
31 {
32 $transaction->process();
33 }
34 $this->factory->miolo->ProfileExit('PersistentManager::Execute');
35 }
36
37 public function retrieveObject(PersistentObject $object)
38 {
39 $classMap = $this->factory->getClassMap($object);
40 $db = $this->getConnection($classMap->getDatabase());
41 $this->_retrieveObject($object, $classMap, $db);
42 }
43
44 public function retrieveObjectFromQuery(PersistentObject $object, MQuery $query)
45 {
46 $classMap = $this->factory->getClassMap($object);
47 $db = $this->getConnection($classMap->getDatabase());
48
49 if (!$query->eof)
50 {
51 $classMap->retrieveObject($object, $query);
52 $this->_retrieveAssociations($object, $classMap, $db);
53 }
54 }
55
56 public function retrieveObjectFromCriteria(PersistentObject $object, PersistentCriteria $criteria, $parameters=NULL)
57 {
58 $classMap = $this->factory->getClassMap($object);
59 $db = $this->getConnection($classMap->getDatabase());
60 $query = $this->processCriteriaQuery($criteria, $parameters, $db, FALSE);
61 if (!$query->eof)
62 {
63 $classMap->retrieveObject($object, $query);
64 $this->_retrieveAssociations($object, $classMap, $db);
65 }
66 }
67
68 public function retrieveObjectAsProxy(PersistentObject $object)
69 {
70 $classMap = $this->factory->getClassMap($object);
71 $db = $this->getConnection($classMap->getDatabase());
72 $this->_retrieveObjectAsProxy($object, $classMap, $db);
73 }
74
75 public function retrieveAssociations(PersistentObject $object)
76 {
77 $classMap = $this->factory->getClassMap($object);
78 $db = $this->getConnection($classMap->getDatabase());
79 $this->_retrieveAssociations($object, $classMap, $db);
80 }
81
82 public function retrieveAssociation(PersistentObject $object, $target, $distinct = false)
83 {
84 $classMap = $this->factory->getClassMap($object);
85 $db = $this->getConnection($classMap->getDatabase());
86 $this->_retrieveAssociation($object, $target, $classMap, $db, $distinct);
87 }
88
89 public function retrieveAssociationAsCursor(PersistentObject $object, $target)
90 {
91 $classMap = $this->factory->getClassMap($object);
92 $db = $this->getConnection($classMap->getDatabase());
93 $this->_retrieveAssociationAsCursor($object, $target, $classMap, $db);
94 }
95
96 public function deleteAssociation(PersistentObject $object, $target, PersistentObject $assocObject)
97 {
98 $classMap = $this->factory->getClassMap($object);
99 $db = $this->getConnection($classMap->getDatabase());
100 $commands = array();
101 $this->_deleteAssociation($object, $target, $assocObject, $commands, $classMap, $db);
102 $this->execute($db, $commands, $object->getTransaction());
103 }
104
105 public function saveAssociation(PersistentObject $object, $target)
106 {
107 $classMap = $this->factory->getClassMap($object);
108 $db = $this->getConnection($classMap->getDatabase());
109 $commands = array();
110 $this->_saveAssociation($object, $target, $commands, $classMap, $db);
111 $this->execute($db, $commands, $object->getTransaction());
112 }
113
114 public function saveObject(PersistentObject $object)
115 {
116 $classMap = $this->factory->getClassMap($object);
117 $db = $this->getConnection($classMap->getDatabase());
118 $commands = array();
119 $this->_saveObject($object, $classMap, $commands, $db);
120 $this->execute($db, $commands, $object->getTransaction());
121 }
122
123 public function saveObjectRaw(PersistentObject $object)
124 {
125 $classMap = $this->factory->getClassMap($object);
126 $db = $this->getConnection($classMap->getDatabase());
127 $commands = array();
128 $this->_saveObjectRaw($object, $classMap, $commands, $db);
129 $this->execute($db, $commands, $object->getTransaction());
130 }
131
132 public function deleteObject(PersistentObject $object)
133 {
134 $classMap = $this->factory->getClassMap($object);
135 $db = $this->getConnection($classMap->getDatabase());
136 $commands = array();
137 $this->_deleteObject($object, $classMap, $commands, $db);
138 $this->execute($db, $commands, $object->getTransaction());
139 }
140
141 private function _retrieveObject(PersistentObject $object, ClassMap $classMap, MDatabase $db, $isLock = FALSE)
142 {
143 $statement = $classMap->getSelectSqlFor($object);
144 $query = $db->GetQuery($statement);
145 if (!$query->eof)
146 {
147 $classMap->retrieveObject($object, $query);
148 $this->_retrieveAssociations($object, $classMap, $db);
149 }
150 }
151
152 private function _retrieveObjectAsProxy(PersistentObject $object, ClassMap $classMap, MDatabase $db, $isLock = FALSE)
153 {
154 $statement = $classMap->getSelectProxySqlFor($object);
155 $query = $db->GetQuery($statement);
156
157 if (!$query->eof)
158 {
159 $classMap->retrieveProxyObject($object, $query);
160 $this->_retrieveAssociations($object, $classMap, $db);
161 }
162 }
163
164 public function _retrieveAssociations(PersistentObject $object, ClassMap $classMap, MDatabase $db)
165 {
166 if ($classMap->getSuperClass() != NULL)
167 {
168 $this->_retrieveAssociations($object, $classMap->getSuperClass(), $db);
169 }
170 $associations = $classMap->getAssociationMaps();
171 foreach ($associations as $aMap)
172 {
173 if ($aMap->isRetrieveAutomatic() && !$aMap->isJoinAutomatic())
174 {
175 $this->__retrieveAssociation($object, $aMap, $classMap, $db);
176 }
177 }
178 }
179
180 private function _retrieveAssociation(PersistentObject $object, $target, ClassMap $classMap, MDatabase $db, $distinct = false)
181 {
182 $aMap = $classMap->getAssociationMap($target);
183 if (is_null($aMap))
184 {
185 throw new EPersistentManagerException("Association name for target $target not found");
186 }
187 if (is_null($aMap->getTarget()))
188 {
189 throw new EPersistentManagerException("Target attribute with name $target not found");
190 }
191 $this->__retrieveAssociation($object, $aMap, $classMap, $db, $distinct);
192 }
193
194 private function _retrieveAssociationAsCursor(PersistentObject $object, $target, ClassMap $classMap, MDatabase $db)
195 {
196 $aMap = $classMap->getAssociationMap($target);
197 if (is_null($aMap))
198 {
199 throw new EPersistentManagerException("Association name for target $target not found");
200 }
201 if (is_null($aMap->getTarget()))
202 {
203 throw new EPersistentManagerException("Target attribute with name $target not found");
204 }
205 $orderAttributes = $aMap->getOrderAttributes();
206 $criteria = $aMap->getCriteria($orderAttributes, $this);
207 $criteriaParameters = $aMap->getCriteriaParameters($object);
208 $cursor = $this->processCriteriaCursor($criteria, $criteriaParameters, $db, FALSE);
209 $aMap->getTarget()->setValue($object, $cursor);
210 }
211
212 private function _deleteAssociation(PersistentObject $object, $target, PersistentObject $assocObject, &$commands, ClassMap $classMap, MDatabase $db)
213 {
214 $aMap = $classMap->getAssociationMap($target);
215 if (is_null($aMap))
216 {
217 throw new EPersistentManagerException("Association name for target $target not found");
218 }
219 if (is_null($aMap->getTarget()))
220 {
221 throw new EPersistentManagerException("Target attribute with name $target not found");
222 }
223 $this->__deleteAssociation($object, $aMap, $assocObject, $commands, $classMap, $db);
224 }
225
226 private function _saveAssociation(PersistentObject $object, $target, &$commands, ClassMap $classMap, MDatabase $db)
227 {
228 $aMap = $classMap->getAssociationMap($target);
229 if (is_null($aMap))
230 {
231 throw new EPersistentManagerException("Association name for target $target not found");
232 }
233 if (is_null($aMap->getTarget()))
234 {
235 throw new EPersistentManagerException("Target attribute with name $target not found");
236 }
237 $this->__saveAssociation($object, $aMap, $commands, $classMap, $db);
238 }
239
240 private function __retrieveAssociation(PersistentObject $object, UniDirectionalAssociationMap $aMap, ClassMap $classMap, MDatabase $db, $distinct = false)
241 {
242 $orderAttributes = $aMap->getOrderAttributes();
243 $criteria = $aMap->getCriteria($orderAttributes, $this);
244 $criteria->setDistinct($distinct);
245 $criteriaParameters = $aMap->getCriteriaParameters($object);
246 $cursor = $this->processCriteriaCursor($criteria, $criteriaParameters, $db, FALSE);
247
248 if ($aMap->getCardinality() == 'oneToOne')
249 {
250 $value = $cursor->getObject();
251 $target = $aMap->getTarget();
252 $target->setValue($object, $value);
253 }
254 elseif (($aMap->getCardinality() == 'oneToMany') || ($aMap->getCardinality() == 'manyToMany'))
255 {
256 $target = $aMap->getTarget();
257 $i = $aMap->getIndexAttribute();
258 while ($o = $cursor->getObject())
259 {
260 if (!is_null($i))
261 $value[$o->$i] = $o;
262 else
263 $value[] = $o;
264 }
265 $target->setValue($object, $value);
266 }
267 }
268
269 private function __deleteAssociation(PersistentObject $object, UniDirectionalAssociationMap $aMap, PersistentObject $assocObject, &$commands, ClassMap $classMap, MDatabase $db)
270 {
271 if (($aMap->getCardinality() == 'oneToOne') || ($aMap->getCardinality() == 'oneToMany'))
272 {
273 if ($aMap->IsInverse())
274 {
275 $classMap = $this->factory->getClassMap($assocObject);
276
277 for ($i = 0; $i < $aMap->getSize(); $i++)
278 {
279 $aMap->getEntry($i)->getFrom()->setValue($assocObject, ':NULL');
280 }
281
282 $statement = $classMap->getUpdateSqlFor($assocObject);
283 $commands[] = $statement->Update();
284 }
285 else
286 {
287 $target = $aMap->getTarget();
288 $target->setValue($object, NULL);
289
290 for ($i = 0; $i < $aMap->getSize(); $i++)
291 {
292 $aMap->getEntry($i)->getFrom()->setValue($object, ':NULL');
293 }
294
295 $statement = $classMap->getUpdateSqlFor($object);
296 $commands[] = $statement->Update();
297 }
298 }
299 elseif ($aMap->getCardinality() == 'manyToMany')
300 {
301 $associativeClassMap = $aMap->getAssociativeClass();
302 $associativeObject = $associativeClassMap->getObject();
303 $criteria = new DeleteCriteria($associativeClassMap, $this);
304 $direction = $aMap->getDirection();
305 $amA = $associativeClassMap->getAssociationMap($direction[0]);
306
307 for ($i = 0; $i < $amA->getSize(); $i++)
308 {
309 $am = $amA->getEntry($i)->getFrom();
310 $keyValue = $am->getValue($object);
311 $criteria->addCriteria($am, '=', $keyValue);
312 }
313
314 $amA = $associativeClassMap->getAssociationMap($direction[1]);
315
316 for ($i = 0; $i < $amA->getSize(); $i++)
317 {
318 $am = $amA->getEntry($i)->getFrom();
319 $keyValue = $am->getValue($assocObject);
320 $criteria->addCriteria($am, '=', $keyValue);
321 }
322
323 $commands[] = $criteria->getSqlStatement()->Delete();
324 }
325
326 $this->__retrieveAssociation($object, $aMap, $classMap, $db);
327 }
328
329 private function __saveStraightAssociation(PersistentObject $object, UniDirectionalAssociationMap $aMap, &$commands, ClassMap $classMap, MDatabase $db)
330 {
331 if ($aMap->getCardinality() == 'oneToOne')
332 {
333 $value = $aMap->getTarget()->getValue($object);
334 if ($value != NULL)
335 {
336 $this->_saveObject($value, $aMap->getForClass(), $commands, $db);
337 for ($i = 0; $i < $aMap->getSize(); $i++)
338 {
339 $aMap->getEntry($i)->getFrom()->setValue($object, $aMap->getEntry($i)->getTo()->getValue($value));
340 }
341 }
342 }
343 elseif ($aMap->getCardinality() == 'oneToMany')
344 {
345 $collection = $aMap->getTarget()->getValue($object);
346 if (count($collection) > 0)
347 {
348 foreach ($collection as $value)
349 {
350 $this->_saveObject($value, $aMap->getForClass(), $commands, $db);
351 for ($i = 0; $i < $aMap->getSize(); $i++)
352 {
353 $aMap->getEntry($i)->getFrom()->setValue($value, $aMap->getEntry($i)->getTo()->getValue($object));
354 }
355 }
356 }
357 }
358 elseif ($aMap->getCardinality() == 'manyToMany')
359 {
360 $commands = array();
361 $collection = $aMap->getTarget()->getValue($object);
362 if (count($collection) > 0)
363 {
364 $associativeClassMap = $aMap->getAssociativeClass();
365 $associativeObject = $associativeClassMap->getObject();
366 $criteria = new DeleteCriteria($associativeClassMap, $this);
367 $direction = $aMap->getDirection();
368 $amA = $associativeClassMap->getAssociationMap($direction[0]);
369 for ($i = 0; $i < $amA->getSize(); $i++)
370 {
371 $am = $amA->getEntry($i)->getFrom();
372 $keyValue = $am->getValue($object);
373 $criteria->addCriteria($am, '=', $keyValue);
374 }
375 $commands[] = $criteria->getSqlStatement()->Delete();
376 foreach ($collection as $value)
377 {
378 if (!$value)
379 continue;
380 $amA = $associativeClassMap->getAssociationMap($direction[0]);
381 for ($i = 0; $i < $amA->getSize(); $i++)
382 {
383 $am = $amA->getEntry($i)->getFrom();
384 $am->setValue($associativeObject, $am->getValue($object));
385 }
386 $pmA = $associativeClassMap->getAssociationMap($direction[1]);
387 for ($i = 0; $i < $pmA->getSize(); $i++)
388 {
389 $pm = $pmA->getEntry($i)->getFrom();
390 $pm->setValue($associativeObject, $pm->getValue($value));
391 }
392 $statement = $associativeClassMap->getInsertSqlFor($associativeObject);
393 $commands[] = $statement->Insert();
394 }
395 }
396 }
397 }
398
399 private function __saveInverseAssociation(PersistentObject $object, UniDirectionalAssociationMap $aMap, &$commands, ClassMap $classMap, MDatabase $db)
400 {
401 if ($aMap->getCardinality() == 'oneToOne')
402 {
403 $value = $aMap->getTarget()->getValue($object);
404 if ($value != NULL)
405 {
406 for ($i = 0; $i < $aMap->getSize(); $i++)
407 {
408 $aMap->getEntry($i)->getFrom()->setValue($value, $aMap->getEntry($i)->getTo()->getValue($value));
409 }
410 $this->_saveObject($value, $aMap->getForClass(), $commands, $db);
411 }
412 }
413 elseif (($aMap->getCardinality() == 'oneToMany') || ($aMap->getCardinality() == 'manyToMany'))
414 {
415 $collection = $aMap->getTarget()->getValue($object);
416 if (count($collection) > 0)
417 {
418 foreach ($collection as $value)
419 {
420 for ($i = 0; $i < $aMap->getSize(); $i++)
421 {
422 $aMap->getEntry($i)->getFrom()->setValue($value, $aMap->getEntry($i)->getTo()->getValue($object));
423 }
424 $this->_saveObject($value, $aMap->getForClass(), $commands, $db);
425 }
426 }
427 }
428 }
429
430 private function __saveAssociation(PersistentObject $object, UniDirectionalAssociationMap $aMap, &$commands, ClassMap $classMap, MDatabase $db)
431 {
432 if ($aMap->isInverse())
433 {
434 $this->__saveInverseAssociation($object, $aMap, $commands, $classMap, $db);
435 }
436 else
437 {
438 $this->__saveStraightAssociation($object, $aMap, $commands, $classMap, $db);
439 }
440 }
441
442 private function _saveObject(PersistentObject $object, ClassMap $classMap, &$commands, MDatabase $db)
443 {
444 if ($classMap->getSuperClass() != NULL)
445 {
446 $isPersistent = $object->isPersistent();
447 $this->_saveObject($object, $classMap->getSuperClass(), $commands, $db);
448 $object->setPersistent($isPersistent);
449 }
450
451 if ($object->isPersistent())
452 {
453 $statement = $classMap->getUpdateSqlFor($object);
454 $commands[] = $statement->Update();
455 }
456 else
457 {
458 for ($i = 0; $i < $classMap->getKeySize(); $i++)
459 {
460 $keyAttribute = $classMap->getKeyAttributeMap($i);
461
462 if ($keyAttribute->getColumnMap()->getKeyType() != 'primary')
463 continue;
464 else
465 {
466 if ($keyAttribute->getColumnMap()->getIdGenerator() != NULL)
467 $value = $db->GetNewId($keyAttribute->getColumnMap()->getIdGenerator());
468 else
469 $value = $keyAttribute->getValue($object);
470
471 $keyAttribute->setValue($object, $value);
472 }
473 }
474
475 $statement = $classMap->getInsertSqlFor($object);
476 $commands[] = $statement->Insert();
477 }
478
479 $mmCmd = array();
480
481 $associations = $classMap->getStraightAssociationMaps();
482 foreach ($associations as $aMap)
483 {
484 if ($aMap->isSaveAutomatic())
485 {
486 $this->__saveStraightAssociation($object, $aMap, $mmCmd, $classMap, $db);
487 }
488 }
489
490 $associations = $classMap->getInverseAssociationMaps();
491 foreach ($associations as $aMap)
492 {
493 if ($aMap->isSaveAutomatic())
494 {
495 $this->__saveInverseAssociation($object, $aMap, $mmCmd, $classMap, $db);
496 }
497 }
498
499 if (count($mmCmd))
500 {
501 $commands = array_merge($commands, $mmCmd);
502 }
503
504 $object->setPersistent(true);
505 }
506
507 private function _saveObjectRaw(PersistentObject $object, ClassMap $classMap, &$commands, MDatabase $db)
508 {
509 if ($object->isPersistent())
510 {
511 $statement = $classMap->getUpdateSqlFor($object);
512 $commands[] = $statement->Update();
513 }
514 else
515 {
516 for ($i = 0; $i < $classMap->getKeySize(); $i++)
517 {
518 $keyAttribute = $classMap->getKeyAttributeMap($i);
519
520 if ($keyAttribute->getColumnMap()->getKeyType() != 'primary')
521 continue;
522 else
523 {
524 if ($keyAttribute->getColumnMap()->getIdGenerator() != NULL)
525 $value = $db->GetNewId($keyAttribute->getColumnMap()->getIdGenerator());
526 else
527 $value = $keyAttribute->getValue($object);
528
529 $keyAttribute->setValue($object, $value);
530 }
531 }
532
533 $statement = $classMap->getInsertSqlFor($object);
534 $commands[] = $statement->Insert();
535 }
536
537 $object->setPersistent(true);
538 }
539
540 private function _deleteObject(PersistentObject $object, ClassMap $classMap, &$commands, MDatabase $db)
541 {
542 $associations = $classMap->getStraightAssociationMaps();
543
544 foreach ($associations as $aMap)
545 {
546 if (!$aMap->isDeleteAutomatic())
547 continue;
548
549 if ($aMap->getCardinality() == 'oneToOne')
550 {
551 $value = $aMap->getTarget()->getValue($object);
552
553 if ($value != NULL)
554 {
555 $this->_deleteObject($value, $aMap->getForClass(), $commands, $db);
556
557 for ($i = 0; $i < $aMap->getSize(); $i++)
558 {
559 $aMap->getEntry($i)->getFrom()->setValue($object, NULL);
560 }
561 }
562 }
563 elseif ($aMap->getCardinality() == 'oneToMany')
564 {
565 $collection = $aMap->getTarget()->getValue($object);
566
567 if (count($collection) > 0)
568 {
569 foreach ($collection as $value)
570 {
571 $this->_deleteObject($value, $aMap->getForClass(), $commands, $db);
572
573 for ($i = 0; $i < $aMap->getSize(); $i++)
574 {
575 $aMap->getEntry($i)->getFrom()->setValue($value, NULL);
576 }
577 }
578 }
579 }
580 elseif ($aMap->getCardinality() == 'manyToMany')
581 {
582 $mmCmd = array();
583 $associativeClassMap = $aMap->getAssociativeClass();
584 $associativeObject = $associativeClassMap->getObject();
585 $direction = $aMap->getDirection();
586 $am = $associativeClassMap->getAssociationMap($direction[0])->getEntry(0)->getFrom();
587 $keyValue = $am->getValue($object);
588 $criteria = new DeleteCriteria($associativeClassMap, $this);
589 $criteria->addCriteria($am, '=', $keyValue);
590 $mmCmd[] = $criteria->getSqlStatement()->Delete();
591 }
592 }
593
594 $associations = $classMap->getInverseAssociationMaps();
595
596 foreach ($associations as $aMap)
597 {
598 if (!$aMap->isDeleteAutomatic())
599 continue;
600
601 if ($aMap->getCardinality() == 'oneToOne')
602 {
603 $value = $aMap->getTarget()->getValue($object);
604
605 if ($value != NULL)
606 {
607 for ($i = 0; $i < $aMap->getSize(); $i++)
608 {
609 $aMap->getEntry($i)->getFrom()->setValue($value, NULL);
610 }
611
612 $this->_deleteObject($value, $aMap->getForClass(), $commands, $db);
613 }
614 }
615 elseif (($aMap->getCardinality() == 'oneToMany') || ($aMap->getCardinality() == 'manyToMany'))
616 {
617 $collection = $aMap->getTarget()->getValue($object);
618
619 if (count($collection) > 0)
620 {
621 foreach ($collection as $value)
622 {
623 for ($i = 0; $i < $aMap->getSize(); $i++)
624 {
625 $aMap->getEntry($i)->getFrom()->setValue($value, NULL);
626 }
627
628 $this->_deleteObject($value, $aMap->getForClass(), $commands, $db);
629 }
630 }
631 }
632 }
633
634 $statement = $classMap->getDeleteSqlFor($object);
635 $commands[] = $statement->Delete();
636
637 if (count($mmCmd))
638 $commands = array_merge($mmCmd, $commands);
639
640 if ($classMap->getSuperClass() != NULL)
641 {
642 $this->_deleteObject($object, $classMap->superClass, $commands, $db);
643 }
644
645 $object->setPersistent(FALSE);
646 }
647
648 private function processCriteriaQuery(PersistentCriteria $criteria, $parameters, MDatabase $db, $forProxy = FALSE)
649 {
650 $statement = $criteria->getSqlStatement($forProxy);
651 $statement->SetParameters($parameters);
652 $query = $db->GetQuery($statement);
653 return $query;
654 }
655
656 private function processCriteriaCursor(PersistentCriteria $criteria, $parameters, MDatabase $db, $forProxy = FALSE)
657 {
658 $query = $this->processCriteriaQuery($criteria, $parameters, $db, $forProxy);
659 $cursor = new Cursor($query, $criteria->getClassMap(), $forProxy, $this);
660 return $cursor;
661 }
662
663 public function getRetrieveCriteria(PersistentObject $object)
664 {
665 $classMap = $this->factory->getClassMap($object);
666 $criteria = new RetrieveCriteria($classMap, $this);
667 return $criteria;
668 }
669
670 public function getDeleteCriteria(PersistentObject $object)
671 {
672 $classMap = $this->factory->getClassMap($object);
673 $criteria = new DeleteCriteria($classMap, $this);
674 $criteria->setTransaction($object->getTransaction());
675 return $criteria;
676 }
677
678 public function processCriteriaDelete(DeleteCriteria $criteria, $parameters)
679 {
680 $db = $this->getConnection($criteria->getClassMap()->getDatabase());
681 $statement = $criteria->getSqlStatement();
682 $statement->SetParameters($parameters);
683 $this->execute($db, $statement->delete(), $criteria->getTransaction());
684 }
685
686
687 public function processCriteriaAsQuery(PersistentCriteria $criteria, $parameters)
688 {
689 $db = $this->getConnection($criteria->getClassMap()->getDatabase());
690 $query = $this->processCriteriaQuery($criteria, $parameters, $db, FALSE);
691 return $query;
692 }
693
694 public function processCriteriaAsCursor(PersistentCriteria $criteria, $parameters)
695 {
696 $db = $this->getConnection($criteria->getClassMap()->getDatabase());
697 $cursor = $this->processCriteriaCursor($criteria, $parameters, $db, FALSE);
698 return $cursor;
699 }
700
701 public function processCriteriaAsProxyQuery(PersistentCriteria $criteria, $parameters)
702 {
703 $db = $this->getConnection($criteria->getClassMap()->getDatabase());
704 $query = $this->processCriteriaQuery($criteria, $parameters, $db, true);
705 return $query;
706 }
707
708 public function processCriteriaAsProxyCursor(PersistentCriteria $criteria, $parameters)
709 {
710 $db = $this->getConnection($criteria->getClassMap()->getDatabase());
711 $cursor = $this->processCriteriaCursor($criteria, $parameters, $db, true);
712 return $cursor;
713 }
714
715 public function getConnection($dbName)
716 {
717 if ($this->closed)
718 {
719 throw new EPersistenManagerException("Persistent Manager is closed!");
720 }
721 if ($this->active)
722 {
723 if (($conn = $this->dbConnections[$dbName]) == NULL)
724 {
725 $conn = $this->factory->miolo->GetDatabase($dbName);
726 $this->dbConnections[$dbName] = $conn;
727 }
728 }
729 else
730 {
731 $conn = $this->factory->miolo->GetDatabase($dbName);
732 }
733
734 return $conn;
735 }
736}
737?>
retrieveProxyObject($object, $query)
Definição classmap.class:300
getInverseAssociationMaps()
Definição classmap.class:217
getSuperClass()
Definição classmap.class:103
getSelectProxySqlFor($object)
Definição classmap.class:357
retrieveObject($object, $query)
Definição classmap.class:257
getStraightAssociationMaps()
Definição classmap.class:212
getAssociationMaps()
Definição classmap.class:202
getDeleteSqlFor($object)
Definição classmap.class:682
getKeyAttributeMap($index)
Definição classmap.class:155
getInsertSqlFor($object)
Definição classmap.class:642
getAssociationMap($name)
Definição classmap.class:175
getSelectSqlFor($object)
Definição classmap.class:343
getUpdateSqlFor($object)
Definição classmap.class:575
GetNewId($sequence='admin', $tableGenerator='miolo_sequence')
GetQuery($sql, $maxrows=0)
_retrieveAssociations(PersistentObject $object, ClassMap $classMap, MDatabase $db)
saveObjectRaw(PersistentObject $object)
processCriteriaAsQuery(PersistentCriteria $criteria, $parameters)
getRetrieveCriteria(PersistentObject $object)
saveAssociation(PersistentObject $object, $target)
__construct(PersistentManagerFactory $factory)
retrieveObject(PersistentObject $object)
retrieveObjectAsProxy(PersistentObject $object)
saveObject(PersistentObject $object)
retrieveAssociations(PersistentObject $object)
deleteAssociation(PersistentObject $object, $target, PersistentObject $assocObject)
getDeleteCriteria(PersistentObject $object)
processCriteriaAsProxyQuery(PersistentCriteria $criteria, $parameters)
retrieveObjectFromCriteria(PersistentObject $object, PersistentCriteria $criteria, $parameters=NULL)
deleteObject(PersistentObject $object)
retrieveObjectFromQuery(PersistentObject $object, MQuery $query)
processCriteriaAsCursor(PersistentCriteria $criteria, $parameters)
retrieveAssociationAsCursor(PersistentObject $object, $target)
processCriteriaDelete(DeleteCriteria $criteria, $parameters)
processCriteriaAsProxyCursor(PersistentCriteria $criteria, $parameters)
retrieveAssociation(PersistentObject $object, $target, $distinct=false)