ManyToManyLinkedFull.class.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************************
00003  *   Copyright (C) 2005-2007 by Konstantin V. Arkhipov                     *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU Lesser General Public License as        *
00007  *   published by the Free Software Foundation; either version 3 of the    *
00008  *   License, or (at your option) any later version.                       *
00009  *                                                                         *
00010  ***************************************************************************/
00011 
00015     final class ManyToManyLinkedFull extends ManyToManyLinkedWorker
00016     {
00020         public function sync($insert, $update = array(), $delete)
00021         {
00022             $dao = $this->container->getDao();
00023             
00024             $db = DBPool::getByDao($dao);
00025             
00026             if ($insert)
00027                 for ($i = 0, $size = count($insert); $i < $size; ++$i) {
00028                     $db->queryNull(
00029                         $this->makeInsertQuery(
00030                             $dao->take($insert[$i])->getId()
00031                         )
00032                     );
00033                 }
00034             
00035             if ($update)
00036                 for ($i = 0, $size = count($update); $i < $size; ++$i)
00037                     $dao->save($update[$i]);
00038             
00039             if ($delete) {
00040                 $ids = array();
00041                 
00042                 foreach ($delete as $object)
00043                     $ids[] = $object->getId();
00044                 
00045                 $db->queryNull($this->makeDeleteQuery($ids));
00046                 
00047                 $dao->uncacheByIds($ids);
00048             }
00049             
00050             return $this;
00051         }
00052         
00056         public function makeFetchQuery()
00057         {
00058             return
00059                 $this->joinHelperTable(
00060                     $this->makeSelectQuery()
00061                 );
00062         }
00063     }
00064 ?>