<?php

namespace Application\Service\DB\Item;

use Interop\Container\ContainerInterface;

class ItemResultidentify extends \Application\Service\DB\AbstractDb
{
    public function __construct($dbAdapter, ContainerInterface $container)
    {
        if (!$this->tableName) {
            $this->tableName = 'yikeen_item_resultidentify';
        }

        parent::__construct($dbAdapter, $container);
    }


    /**
     * Notes: 获取对应数组
     * @param  $where 条件
     * @param  $filed  查询字段 $type 1 一对一 2 一对多
     * @return array
     * @author haojinhua
     * @date 2024-05-21
     */
    public function getFiledRelation($where,$key,$filed,$type){
        $res = [];
        $where = empty($where) ? 'is_del = 0' : $where;
        $cond = [
            'where' => $where,
            'columns' => $filed,
            'order' => ['id'],
        ];
        $datas = $this->fetchAll($cond);
        if(!empty($datas)){
            foreach ($datas as $data){
                if($type == 1){
                    $res[$data[$key]] = $data;
                }else{
                    $res[$data[$key]][] = $data;
                }
            }
        }

        return $res;
    }

}
