<?php
/**
 *
 * @author：llbjj
 * @DateTime：2022/5/6 10:57
 * @Description：
 *
 */

namespace Application\Service\DB\Dictionary;

use Interop\Container\ContainerInterface;

class Eventset extends \Application\Service\DB\AbstractDb
{
    public function __construct($dbAdapter, ContainerInterface $container)
    {
        $this->tableName = 'yikeen_dictionary_eventset';
        parent::__construct($dbAdapter, $container);
    }

    public function fetchDataBykey($where,$columns,$key,$is_more=0){
        $res = [];
        $where = empty($where) ? 'is_del = 0' : $where;
        $cond = [
            'where' => $where,
            'columns' => $columns,
            'order' => ['id'],
        ];
        $datas = $this->fetchAll($cond);
        if(!empty($datas)){
            foreach ($datas as $data){
                $data_key = $data[$key];
                if($is_more == 1){
                    $res[$data_key][] = $data;
                }else{
                    $res[$data_key] = $data;
                }
            }
        }

        return  $res;
    }

}