This repository has been archived on 2026-09-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ku-web-comp/app/Models/ItemModel.php
T
2026-09-20 13:07:50 +07:00

33 lines
719 B
PHP

<?php
namespace App\Models;
use CodeIgniter\Model;
class ItemModel extends model {
protected $table = 'item';
public function getItem($itemId = false) {
if ($itemId === false) {
return $this->findAll();
}
return $this->where(['itemId' => $itemId])->first();
}
public function getCount() {
return $this->db->count_all($this->table);
}
public function getStar(?int $perPage = null): array
{
$this->builder()
->select('item.*, star.star')
->join('star', 'star.itemId = item.itemId');
return [
'star' => $this->paginate($perPage),
'starpager' => $this->pager,
];
}
}