LogicalBetween.class.php

Go to the documentation of this file.
00001 <?php
00002 /****************************************************************************
00003  *   Copyright (C) 2004-2007 by Konstantin V. Arkhipov, Anton E. Lebedevich *
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: LogicalBetween.class.php 4687 2007-12-09 18:57:18Z voxus $ */
00012 
00018     final class LogicalBetween implements LogicalObject, MappableObject
00019     {
00020         private $field  = null;
00021         private $left   = null;
00022         private $right  = null;
00023         
00024         public function __construct($field, $left, $right)
00025         {
00026             $this->left     = $left;
00027             $this->right    = $right;
00028             $this->field    = $field;
00029         }
00030         
00031         public function toDialectString(Dialect $dialect)
00032         {
00033             return
00034                 '('
00035                 .$dialect->toFieldString($this->field)
00036                 .' BETWEEN '
00037                 .$dialect->toValueString($this->left)
00038                 .' AND '
00039                 .$dialect->toValueString($this->right)
00040                 .')';
00041         }
00042         
00046         public function toMapped(StorableDAO $dao, JoinCapableQuery $query)
00047         {
00048             return new self(
00049                 $dao->guessAtom($this->field, $query),
00050                 $dao->guessAtom($this->left, $query),
00051                 $dao->guessAtom($this->right, $query)
00052             );
00053         }
00054         
00055         public function toBoolean(Form $form)
00056         {
00057             $left   = $form->toFormValue($this->left);
00058             $right  = $form->toFormValue($this->right);
00059             $value  = $form->toFormValue($this->field);
00060             
00061             return ($left   <= $value)
00062                 && ($value  <= $right);
00063         }
00064     }
00065 ?>

Generated on Sun Dec 9 21:56:23 2007 for onPHP by  doxygen 1.5.4