1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-24 20:06:09 +08:00
2020-03-16 15:33:36 +08:00

63 lines
1.3 KiB
PHP

<?php
namespace App\Repos;
use App\Models\Config as ConfigModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class Config extends Repository
{
/**
* @param string $section
* @param string $itemKey
* @return ConfigModel|Model|bool
*/
public function findItem($section, $itemKey)
{
$result = ConfigModel::findFirst([
'conditions' => 'section = :section: AND item_key = :item_key:',
'bind' => ['section' => $section, 'item_key' => $itemKey],
]);
return $result;
}
/**
* @param string $section
* @return Resultset|ResultsetInterface|ConfigModel[]
*/
public function findBySection($section)
{
$query = ConfigModel::query();
$query->where('section = :section:', ['section' => $section]);
$result = $query->execute();
return $result;
}
/**
* @param array $where
* @return Resultset|ResultsetInterface|ConfigModel[]
*/
public function findAll($where = [])
{
$query = ConfigModel::query();
$query->where('1 = 1');
if (!empty($where['section'])) {
$query->andWhere('section = :section:', ['section' => $where['section']]);
}
$result = $query->execute();
return $result;
}
}