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 /* $Id: OneToManyLinkedFull.class.php 4687 2007-12-09 18:57:18Z voxus $ */ 00012 00016 final class OneToManyLinkedFull extends OneToManyLinkedWorker 00017 { 00021 public function makeFetchQuery() 00022 { 00023 return $this->targetize($this->makeSelectQuery()); 00024 } 00025 00029 public function sync(&$insert, &$update = array(), &$delete) 00030 { 00031 $uc = $this->container; 00032 $dao = $uc->getDao(); 00033 00034 if ($delete) { 00035 DBPool::getByDao($dao)->queryNull( 00036 OSQL::delete()->from($dao->getTable())-> 00037 where( 00038 Expression::eq( 00039 new DBField($uc->getParentIdField()), 00040 $uc->getParentObject()->getId() 00041 ) 00042 )-> 00043 andWhere( 00044 Expression::in( 00045 $uc->getChildIdField(), 00046 ArrayUtils::getIdsArray($delete) 00047 ) 00048 ) 00049 ); 00050 00051 $dao->uncacheByIds(ArrayUtils::getIdsArray($delete)); 00052 } 00053 00054 if ($insert) 00055 for ($i = 0, $size = count($insert); $i < $size; ++$i) 00056 $dao->add($insert[$i]); 00057 00058 if ($update) 00059 for ($i = 0, $size = count($update); $i < $size; ++$i) 00060 $dao->save($update[$i]); 00061 00062 return $this; 00063 } 00064 } 00065 ?>