Source of file OrmObjectlistInOrEmptyRestriction.php

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

buildproject/core/module_system/system/OrmObjectlistInOrEmptyRestriction.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
<?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 objectlist restriction may be used to create where restrictions for the objectList and objectCount queries.
 * This restrcition creates an IN statement e.g. "AND <columnname> IN (<parameters>)"
 *
 * @package module_system
 * @author stefan.meyer1@yahoo.de
 * @since 4.8
 * 
 * @deprecated
 */
class OrmObjectlistInOrEmptyRestriction extends OrmObjectlistInRestriction
{
    const NULL_OR_EMPTY = "NULL_OR_EMPTY";

    private $bitIncludeNullOrEmptyValues = false;

    /**
     * OrmObjectlistInOrEmptyRestriction constructor.
     *
     * @param bool $bitIncludeNullOrEmptyValues
     *
     * @deprecated
     */
    function __construct($strProperty, array $arrParams, $strCondition = "AND", $strInCondition = self::STR_CONDITION_IN)
    {
        parent::__construct($strProperty, $arrParams, $strCondition, $strInCondition);

        if(in_array(self::NULL_OR_EMPTY, $this->arrParams)) {
            $this->bitIncludeNullOrEmptyValues = true;
        }
    }


    /**
     * @param $strColumnName
     * @param $strCondition
     *
     * @return string
     */
    protected function addAdditionalConditions($strColumnName, $strCondition)
    {
        if($this->bitIncludeNullOrEmptyValues) {
            return "$strCondition ($strColumnName IS NULL OR $strColumnName = '')";
        }

        return "";
    }
}