ManyToManyLinkedLazy.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 ManyToManyLinkedLazy extends ManyToManyLinkedWorker
00016     {
00021         public function sync($insert, $update = array(), $delete)
00022         {
00023             Assert::isTrue($update === array());
00024             
00025             $dao = $this->container->getDao();
00026             
00027             $db = DBPool::getByDao($dao);
00028             
00029             if ($insert)
00030                 for ($i = 0, $size = count($insert); $i < $size; ++$i)
00031                     $db->queryNull($this->makeInsertQuery($insert[$i]));
00032 
00033             if ($delete) {
00034                 $db->queryNull($this->makeDeleteQuery($delete));
00035                 
00036                 $dao->uncacheByIds($delete);
00037             }
00038 
00039             return $this;
00040         }
00041         
00045         public function makeFetchQuery()
00046         {
00047             $uc = $this->container;
00048             
00049             return
00050                 $this->joinHelperTable(
00051                     $this->makeSelectQuery()->
00052                     dropFields()->
00053                     get(
00054                         new DBField(
00055                             $uc->getChildIdField(),
00056                             $uc->getHelperTable()
00057                         )
00058                     )
00059                 );
00060         }
00061     }
00062 ?>