Source of file OrmPropertyInCondition.php

Size: 1,891 Bytes - Last Modified: 2016-05-18T03:08:27+02:00

buildproject/core/module_system/system/OrmPropertyInCondition.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
<?php
/*"******************************************************************************************************
*   (c) 2007-2016 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*   $Id$                                        *
********************************************************************************************************/

namespace Kajona\System\System;


/**
 * A orm condition may be used to create where conditions for the objectList and objectCount queries.
 * This condition creates an IN statement e.g. "AND <columnname> IN (<parameters>)"
 *
 * @package Kajona\System\System
 * @author stefan.meyer1@yahoo.de
 * @since 5.0
 */
class OrmPropertyInCondition extends OrmInCondition
{
    public function __construct($strProperty, array $arrParams, $strInCondition = self::STR_CONDITION_IN)
    {
        parent::__construct($strProperty, $arrParams, $strInCondition);
    }

    /**
     * Here comes the magic, generation a where restriction out of the passed property name and the comparator
     *
     * @return string
     * @throws OrmException
     */
    public function getStrWhere()
    {
        $objReflection = new Reflection($this->getStrTargetClass());

        $strPropertyValue = $objReflection->getAnnotationValueForProperty($this->strColumnName, OrmBase::STR_ANNOTATION_TABLECOLUMN);

        if ($strPropertyValue == null) {
            throw new OrmException("Failed to load annotation ".OrmBase::STR_ANNOTATION_TABLECOLUMN." for property ".$this->strColumnName."@".$this->getStrTargetClass(), OrmException::$level_ERROR);
        }


        return $this->getInStatement($strPropertyValue);
    }

}