워커 수정
This commit is contained in:
@@ -8,64 +8,85 @@ class CodeModel extends Model
|
||||
/**
|
||||
* 코드목록 읽어오기(Y만)
|
||||
*/
|
||||
public function getCodeList($category)
|
||||
{
|
||||
$sql = "SELECT category, category_nm, cd, cd_nm FROM codes" .
|
||||
" WHERE category = ?" .
|
||||
" AND use_yn = 'Y'" .
|
||||
" ORDER BY view_odr";
|
||||
$data = [$category];
|
||||
$query = $this->db->query($sql, $data);
|
||||
|
||||
return $query->getResultArray();
|
||||
}
|
||||
|
||||
|
||||
public function getCodeLists($data): array
|
||||
public function getCodeList(string $category): array
|
||||
{
|
||||
return $this->db->table('codes')
|
||||
->select('category, category_nm, cd, cd_nm')
|
||||
->whereIn('category', $data)
|
||||
->where('category', $category)
|
||||
->where('use_yn', 'Y')
|
||||
->orderBy('view_odr')
|
||||
->orderBy('view_odr', 'asc')
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function getCategoryCodeList($category = [], $useYn = '')
|
||||
|
||||
public function getCodeLists(array $categories): array
|
||||
{
|
||||
$this->db->select('category, cd, cd_nm, use_yn');
|
||||
$this->db->from('codes');
|
||||
$this->db->where_in('category', $category);
|
||||
if (!empty($useYn)) {
|
||||
$this->db->where('use_yn', $useYn);
|
||||
if (empty($categories)) {
|
||||
return [];
|
||||
}
|
||||
$this->db->order_by('category', 'asc');
|
||||
$this->db->order_by('view_odr', 'asc');
|
||||
|
||||
$query = $this->db->get();
|
||||
$result = $this->db->table('codes')
|
||||
->select('category, category_nm, cd, cd_nm')
|
||||
->whereIn('category', $categories)
|
||||
->where('use_yn', 'Y')
|
||||
->orderBy('category', 'asc')
|
||||
->orderBy('view_odr', 'asc')
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
//echo $this->db->last_query()."<br>";
|
||||
$groupedData = [];
|
||||
foreach ($result as $item) {
|
||||
$category = $item['category'];
|
||||
|
||||
if (!isset($groupedData[$category])) {
|
||||
$groupedData[$category] = [
|
||||
'name' => $item['category_nm'],
|
||||
'items' => []
|
||||
];
|
||||
}
|
||||
|
||||
$groupedData[$category]['items'][$item['cd']] = $item['cd_nm'];
|
||||
}
|
||||
|
||||
return $groupedData;
|
||||
}
|
||||
|
||||
public function getCategoryCodeList(array $category = [], string $useYn = ''): array
|
||||
{
|
||||
if (empty($category)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$builder = $this->db->table('codes');
|
||||
$builder->select('category, cd, cd_nm, use_yn');
|
||||
$builder->whereIn('category', $category);
|
||||
if (!empty($useYn)) {
|
||||
$builder->where('use_yn', $useYn);
|
||||
}
|
||||
$builder->orderBy('category', 'asc');
|
||||
$builder->orderBy('view_odr', 'asc');
|
||||
|
||||
$query = $builder->get();
|
||||
|
||||
//여기 아래부분을 해줘야 배열을 카테고리로 뽑아쓸수있다 위에는 배열에 배열이담김
|
||||
$codes = [];
|
||||
foreach ($query->getResultArray() as $row) {
|
||||
$codes[$row['category']][] = ['cd' => $row['cd'], 'cd_nm' => $row['cd_nm']];
|
||||
}
|
||||
|
||||
return $codes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 코드 상세
|
||||
*/
|
||||
public function getCodeDetail($category, $code)
|
||||
public function getCodeDetail(string $category, string $code): array
|
||||
{
|
||||
$sql = "SELECT category, category_nm, cd, cd_nm FROM codes" .
|
||||
" WHERE category = ? and cd = ?";
|
||||
$data = [$category, $code];
|
||||
$query = $this->db->query($sql, $data);
|
||||
$row = $query->getResultArray();
|
||||
|
||||
return $row;
|
||||
return $this->db->table('codes')
|
||||
->select('category, category_nm, cd, cd_nm')
|
||||
->where('category', $category)
|
||||
->where('cd', $code)
|
||||
->get()
|
||||
->getResultArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user