ModuleProperty_MapperProperty

Package application.modules.property
Inheritance class ModuleProperty_MapperProperty » Mapper » LsObject
Since 2.0
Source Code /application/classes/modules/property/mapper/Property.mapper.class.php
Маппер для работы с БД

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
_aBehaviors Список поведений в виде готовых объектов, формируется автоматически LsObject
aBehaviors array Список поведений LsObject
oDb DbSimple_Database Объект подключения к базе данных Mapper

Public Methods

Hide inherited methods

MethodDescriptionDefined By
AddBehaviorHook() Добавляет хук поведения LsObject
AttachBehavior() Присоединяет поведение к объекту LsObject
DetachBehavior() Отсоединяет поведение от объекта LsObject
GetBehavior() Возвращает объект поведения по его имени LsObject
GetBehaviors() Возвращает все объекты поведения LsObject
GetPropertiesValueByTarget() ModuleProperty_MapperProperty
GetPropertiesValueByTargetArray() ModuleProperty_MapperProperty
GetPropertyTagsByLike() ModuleProperty_MapperProperty
GetPropertyTagsGroup() ModuleProperty_MapperProperty
GetTargetsByTag() ModuleProperty_MapperProperty
RemoveBehaviorHook() Удаляет хук поведения LsObject
RemoveSelectByPropertyId() ModuleProperty_MapperProperty
RemoveValueByPropertyId() ModuleProperty_MapperProperty
RemoveValueSelectByPropertyId() ModuleProperty_MapperProperty
RemoveValueSelectsByTarget() ModuleProperty_MapperProperty
RemoveValueTagByPropertyId() ModuleProperty_MapperProperty
RemoveValueTagsByTarget() ModuleProperty_MapperProperty
RunBehaviorHook() Запускает хук поведения на выполнение LsObject
UpdatePropertyByTargetType() ModuleProperty_MapperProperty
UpdatePropertySelectByTargetType() ModuleProperty_MapperProperty
UpdatePropertyTargetByTargetType() ModuleProperty_MapperProperty
UpdatePropertyValueByTargetType() ModuleProperty_MapperProperty
UpdatePropertyValueSelectByTargetType() ModuleProperty_MapperProperty
UpdatePropertyValueTagByTargetType() ModuleProperty_MapperProperty
__call() Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля LsObject
__clone() При клонировании сбрасываем поведения LsObject
__construct() Передаем коннект к БД Mapper
__get() Обработка доступа к объекты поведения LsObject

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
IsSuccessful() Mapper
PrepareBehaviors() Инициализация поведений LsObject

Method Details

GetPropertiesValueByTarget() method
public void GetPropertiesValueByTarget($sTargetType, $iTargetId)
$sTargetType
$iTargetId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#31 (show)
public function GetPropertiesValueByTarget($sTargetType$iTargetId)
{
    
$sql "SELECT
                v.*,
                p.id  as prop_id,
                p.target_type   as prop_target_type,
                p.type   as prop_type ,
                p.code  as prop_code,
                p.title  as prop_title,
                p.date_create  as prop_date_create,
                p.sort  as prop_sort,
                p.params  as prop_params
            FROM " 
Config::Get('db.table.property') . " AS p
                 LEFT JOIN " 
Config::Get('db.table.property_value') . " as v on ( v.property_id=p.id and v.target_id = ?d )
            WHERE
                p.target_type = ?
            ORDER BY
                p.sort desc
            limit 0,100"
;

    
$aResult = array();
    if (
$aRows $this->oDb->select($sql$iTargetId$sTargetType)) {
        foreach (
$aRows as $aRow) {
            
$aProperty = array();
            
$aValue = array();
            foreach (
$aRow as $k => $v) {
                if (
strpos($k'prop_') === 0) {
                    
$aProperty[str_replace('prop_'''$k)] = $v;
                } else {
                    
$aValue[$k] = $v;
                }
            }
            
$oProperty Engine::GetEntity('ModuleProperty_EntityProperty'$aProperty);
            
/**
             * На случай, если нет еще значения свойства в БД
             */
            
$aValue['property_id'] = $oProperty->getId();
            
$aValue['property_type'] = $oProperty->getType();
            
$aValue['target_type'] = $sTargetType;
            
$aValue['target_id'] = $iTargetId;
            
$oProperty->setValue(Engine::GetEntity('ModuleProperty_EntityValue'$aValue));
            
$aResult[$oProperty->getId()] = $oProperty;
        }
    }
    return 
$aResult;
}

GetPropertiesValueByTargetArray() method
public void GetPropertiesValueByTargetArray($sTargetType, $aTargetId)
$sTargetType
$aTargetId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#78 (show)
public function GetPropertiesValueByTargetArray($sTargetType$aTargetId)
{
    if (!
is_array($aTargetId)) {
        
$aTargetId = array($aTargetId);
    }
    if (!
$aTargetId) {
        return array();
    }
    
$sql "SELECT
                v.*,
                p.id  as prop_id,
                p.target_type   as prop_target_type,
                p.type   as prop_type ,
                p.code  as prop_code,
                p.title  as prop_title,
                p.date_create  as prop_date_create,
                p.sort  as prop_sort,
                p.params  as prop_params
            FROM " 
Config::Get('db.table.property') . " AS p
                 LEFT JOIN " 
Config::Get('db.table.property_value') . " as v on ( v.property_id=p.id and v.target_id IN ( ?a ) )
            WHERE
                p.target_type = ?
            ORDER BY
                p.sort desc "
;

    
$aResult = array();
    if (
$aRows $this->oDb->select($sql$aTargetId$sTargetType)) {
        return 
$aRows;
    }
    return 
$aResult;
}

GetPropertyTagsByLike() method
public void GetPropertyTagsByLike($sTag, $iPropertyId, $iLimit)
$sTag
$iPropertyId
$iLimit
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#196 (show)
public function GetPropertyTagsByLike($sTag$iPropertyId$iLimit)
{
    
$sTag mb_strtolower($sTag"UTF-8");
    
$sql "SELECT
            text
        FROM
            " 
Config::Get('db.table.property_value_tag') . "
        WHERE
            property_id = ?d and text LIKE ?
        GROUP BY
            text
        LIMIT 0, ?d
            "
;
    
$aReturn = array();
    if (
$aRows $this->oDb->select($sql$iPropertyId$sTag '%'$iLimit)) {
        foreach (
$aRows as $aRow) {
            
$aReturn[] = Engine::GetEntity('ModuleProperty_EntityValueTag'$aRow);
        }
    }
    return 
$aReturn;
}

GetPropertyTagsGroup() method
public void GetPropertyTagsGroup($iPropertyId, $iLimit)
$iPropertyId
$iLimit
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#218 (show)
public function GetPropertyTagsGroup($iPropertyId$iLimit)
{
    
$sql "SELECT
        text,
        count(text)    as count
        FROM
            " 
Config::Get('db.table.property_value_tag') . "
        WHERE
            1=1
            property_id = ?d
        GROUP BY
            text
        ORDER BY
            count desc
        LIMIT 0, ?d
            "
;
    
$aReturn = array();
    
$aReturnSort = array();
    if (
$aRows $this->oDb->select(
        
$sql,
        
$iPropertyId,
        
$iLimit
    
)
    ) {
        foreach (
$aRows as $aRow) {
            
$aReturn[mb_strtolower($aRow['text'], 'UTF-8')] = $aRow;
        }
        
ksort($aReturn);
        foreach (
$aReturn as $aRow) {
            
$aReturnSort[] = Engine::GetEntity('ModuleProperty_EntityValueTag'$aRow);
        }
    }
    return 
$aReturnSort;
}

GetTargetsByTag() method
public void GetTargetsByTag($iPropertyId, $sTag, &$iCount, $iCurrPage, $iPerPage)
$iPropertyId
$sTag
$iCount
$iCurrPage
$iPerPage
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#253 (show)
public function GetTargetsByTag($iPropertyId$sTag, &$iCount$iCurrPage$iPerPage)
{
    
$sql "
                        SELECT
                            target_id
                        FROM
                            " 
Config::Get('db.table.property_value_tag') . "
                        WHERE
                            property_id  = ?d
                            and
                            text = ?
                        ORDER BY target_id DESC
                        LIMIT ?d, ?d "
;

    
$aReturn = array();
    if (
$aRows $this->oDb->selectPage($iCount$sql$iPropertyId$sTag, ($iCurrPage 1) * $iPerPage,
        
$iPerPage)
    ) {
        foreach (
$aRows as $aTopic) {
            
$aReturn[] = $aTopic['target_id'];
        }
    }
    return 
$aReturn;
}

RemoveSelectByPropertyId() method
public void RemoveSelectByPropertyId($iPropertyId)
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#183 (show)
public function RemoveSelectByPropertyId($iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_select') . "
            WHERE
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

RemoveValueByPropertyId() method
public void RemoveValueByPropertyId($iPropertyId)
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#144 (show)
public function RemoveValueByPropertyId($iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_value') . "
            WHERE
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

RemoveValueSelectByPropertyId() method
public void RemoveValueSelectByPropertyId($iPropertyId)
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#170 (show)
public function RemoveValueSelectByPropertyId($iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_value_select') . "
            WHERE
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

RemoveValueSelectsByTarget() method
public void RemoveValueSelectsByTarget($sTargetType, $iTargetId, $iPropertyId)
$sTargetType
$iTargetId
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#127 (show)
public function RemoveValueSelectsByTarget($sTargetType$iTargetId$iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_value_select') . "
            WHERE
                target_id = ?d
                and
                target_type = ?
                and
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iTargetId$sTargetType$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

RemoveValueTagByPropertyId() method
public void RemoveValueTagByPropertyId($iPropertyId)
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#157 (show)
public function RemoveValueTagByPropertyId($iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_value_tag') . "
            WHERE
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

RemoveValueTagsByTarget() method
public void RemoveValueTagsByTarget($sTargetType, $iTargetId, $iPropertyId)
$sTargetType
$iTargetId
$iPropertyId
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#110 (show)
public function RemoveValueTagsByTarget($sTargetType$iTargetId$iPropertyId)
{
    
$sql "DELETE
            FROM " 
Config::Get('db.table.property_value_tag') . "
            WHERE
                target_id = ?d
                and
                target_type = ?
                and
                property_id = ?d
                "
;
    if (
$this->oDb->query($sql$iTargetId$sTargetType$iPropertyId) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertyByTargetType() method
public void UpdatePropertyByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#278 (show)
public function UpdatePropertyByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property') . "
            SET target_type = ?
            WHERE
                target_type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertySelectByTargetType() method
public void UpdatePropertySelectByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#306 (show)
public function UpdatePropertySelectByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property_select') . "
            SET target_type = ?
            WHERE
                target_type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertyTargetByTargetType() method
public void UpdatePropertyTargetByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#292 (show)
public function UpdatePropertyTargetByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property_target') . "
            SET type = ?
            WHERE
                type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertyValueByTargetType() method
public void UpdatePropertyValueByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#320 (show)
public function UpdatePropertyValueByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property_value') . "
            SET target_type = ?
            WHERE
                target_type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertyValueSelectByTargetType() method
public void UpdatePropertyValueSelectByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#334 (show)
public function UpdatePropertyValueSelectByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property_value_select') . "
            SET target_type = ?
            WHERE
                target_type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}

UpdatePropertyValueTagByTargetType() method
public void UpdatePropertyValueTagByTargetType($sTargetType, $sTargetTypeNew)
$sTargetType
$sTargetTypeNew
Source Code: /application/classes/modules/property/mapper/Property.mapper.class.php#348 (show)
public function UpdatePropertyValueTagByTargetType($sTargetType$sTargetTypeNew)
{
    
$sql "UPDATE
             " 
Config::Get('db.table.property_value_tag') . "
            SET target_type = ?
            WHERE
                target_type = ?
                "
;
    if (
$this->oDb->query($sql$sTargetTypeNew$sTargetType) !== false) {
        return 
true;
    }
    return 
false;
}