00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00016 final class ManyToManyLinkedFull extends ManyToManyLinkedWorker
00017 {
00021 public function sync(&$insert, &$update = array(), &$delete)
00022 {
00023 $dao = $this->container->getDao();
00024
00025 $db = DBPool::getByDao($dao);
00026
00027 if ($insert)
00028 for ($i = 0, $size = count($insert); $i < $size; ++$i) {
00029
00030 try {
00031 $dao->getById($insert[$i]->getId());
00032 } catch (ObjectNotFoundException $e) {
00033
00034 $dao->add($insert[$i]);
00035 }
00036
00037 $db->queryNull(
00038 $this->makeInsertQuery($insert[$i]->getId())
00039 );
00040 }
00041
00042 if ($update)
00043 for ($i = 0, $size = count($update); $i < $size; ++$i)
00044 $dao->save($update[$i]);
00045
00046 if ($delete) {
00047 $ids = array();
00048
00049 foreach ($delete as $object)
00050 $ids[] = $object->getId();
00051
00052 $db->queryNull($this->makeDeleteQuery($ids));
00053
00054 $dao->uncacheByIds($ids);
00055 }
00056
00057 return $this;
00058 }
00059
00063 public function makeFetchQuery()
00064 {
00065 return
00066 $this->joinHelperTable(
00067 $this->makeSelectQuery()
00068 );
00069 }
00070 }
00071 ?>