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 00015 final class EqualsLowerExpression implements LogicalObject, MappableObject 00016 { 00017 private $left = null; 00018 private $right = null; 00019 00020 public function __construct($left, $right) 00021 { 00022 $this->left = $left; 00023 $this->right = $right; 00024 } 00025 00026 public function toDialectString(Dialect $dialect) 00027 { 00028 return 00029 '(' 00030 .$dialect->toFieldString( 00031 SQLFunction::create('lower', $this->left) 00032 ).' = ' 00033 .$dialect->toValueString( 00034 is_string($this->right) 00035 ? mb_strtolower($this->right) 00036 : SQLFunction::create('lower', $this->right) 00037 ) 00038 .')'; 00039 } 00040 00044 public function toMapped(ProtoDAO $dao, JoinCapableQuery $query) 00045 { 00046 return new self( 00047 $dao->guessAtom($this->left, $query), 00048 $dao->guessAtom($this->right, $query) 00049 ); 00050 } 00051 00052 public function toBoolean(Form $form) 00053 { 00054 $left = $form->toFormValue($this->left); 00055 $right = $form->toFormValue($this->right); 00056 00057 $both = 00058 (null !== $left) 00059 && (null !== $right); 00060 00061 return $both && (mb_strtolower($left) === mb_strtolower($right)); 00062 } 00063 } 00064 ?>