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