Your IP : 3.138.137.175


Current Path : /var/www/u0635749/data/www/hobbyclick.ru/src/Metods/
Upload File :
Current File : /var/www/u0635749/data/www/hobbyclick.ru/src/Metods/OrmMetod.php

<?php

namespace Tequila\Metods;

use Tequila\Models\LinkConnectionTable;

class OrmMetod
{
    private $data = [];

    /**
     *Добавление строки в ORM
     **/
    public static function addOrmEl(array $el)
    {
        $result = LinkConnectionTable::add([
            'ID_OFFER' => $el['ID_OFFER'],
            'ID_PRODUCT' => $el['ID_PRODUCT'],
            'ID_TEACHER' => $el['ID_TEACHER'],
            'ID_HALL' => $el['ID_HALL'],
            'TREND' => $el['TREND'],
            'PRICE' => $el['PRICE'],
            'FILTER_STRESS' => $el['FILTER_STRESS'],
            'FILTER_REGION' => $el['FILTER_REGION'],
            'FILTER_MOTIV' => $el['FILTER_MOTIV'],
            'AREA_CITY' => $el['AREA_CITY'],
            'METRO' => $el['METRO'],
            'LEVEL' => $el['LEVEL'],
            'AGE' => $el['AGE'],
            'DAYTIME' => $el['DAYTIME'],
            'FILTER_GENDER' => $el['FILTER_GENDER'],
            'FILTER_FORMAT' => $el['FILTER_FORMAT'],
            'RENT' => $el['RENT'],
        ]);
    
        if ($result->isSuccess()) {
            return $result->getId();
        }
    }



    /**
    *   удалить запись, если сществует на то запрос
    */
    public static function deleteOrmEl(int $item) 
    {
        $list = LinkConnectionTable::getList([
            "select" => ["ID"],
            "filter" => [
                "=ID_OFFER" => $item,
            ],
        ]);

        if ($id = $list->fetch()){
            $result = LinkConnectionTable::Delete($id['ID']);
        } 
    }


    /**
    *   строки в ORM
    *
    *    @return int id записи
    */
    public static function getOrmEl (array $search)
    {
      
        $result = LinkConnectionTable::getList([
            'select' => ['*'],
            'filter' => $search, 
        ]); 

        $field = $result -> fetchAll();

        return $field;
    }


    public static function getOrmHall (array $search)
    {
        $result = LinkConnectionTable::getList([
            'select' => ['*'],
            'filter' => $search, 
        ]); 

        while($arData = $result->Fetch()){
            $hall['ID'][$arData['ID_HALL']] = $arData['ID_HALL'];
        }

        return $hall;
    }


    public static function getOrmTeacher (array $search)
    {
        $result = LinkConnectionTable::getList([
            'select' => ['*'],
            'filter' => $search, 
        ]); 

        while($arData = $result->Fetch()){
            $teacher[$arData['ID_TEACHER']] = $arData['ID_TEACHER'];
        }

        return $teacher;
    }


    public static function getOrmOffer (array $search)
    {
        $result = LinkConnectionTable::getList([
            'select' => ['*'],
            'filter' => $search, 
        ]); 
        
        while($arData = $result->Fetch()){
            $offer[$arData['ID_OFFER']] = $arData['ID_OFFER'];
        }
        return $offer;
    }
}