src/Biz/Group/Dao/Impl/ThreadPostDaoImpl.php

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

<?php

namespace Biz\Group\Dao\Impl;

use Biz\Group\Dao\ThreadPostDao;
use Codeages\Biz\Framework\Dao\DaoException;
use Codeages\Biz\Framework\Dao\GeneralDaoImpl;

class ThreadPostDaoImpl extends GeneralDaoImpl implements ThreadPostDao
{
    protected $table = 'groups_thread_post';

    public function searchPostsThreadIds($conditions, $orderbys, $start, $limit)
    {
        $builder = $this->createQueryBuilder($conditions)
            ->select('distinct threadId, id')
            ->setFirstResult($start)
            ->setMaxResults($limit);

        $declares = $this->declares();
        foreach ($orderbys ?: array() as $field => $direction) {
            if (!in_array($field, $declares['orderbys'])) {
                throw new DaoException(sprintf("SQL order by field is only allowed '%s', but you give `{$field}`.", implode(',', $declares['orderbys'])));
            }
            if (!in_array(strtoupper($direction), array('ASC', 'DESC'))) {
                throw new DaoException("SQL order by direction is only allowed `ASC`, `DESC`, but you give `{$direction}`.");
            }
            $builder->addOrderBy($field, $direction);
        }

        return $builder->execute()->fetchAll() ?: array();
    }

    public function countPostsThreadIds($conditions)
    {
        $builder = $this->createQueryBuilder($conditions)
            ->select('count(distinct threadId)');

        return $builder->execute()->fetchColumn(0);
    }

    public function deleteByThreadId($threadId)
    {
        return $this->db()->delete($this->table, array('threadId' => $threadId));
    }

    public function declares()
    {
        return array(
            'timestamps' => array('createdTime'),
            'serializes' => array('tagIds' => 'json'),
            'orderbys' => array('id', 'createdTime'),
            'conditions' => array(
                'id < :id',
                'userId = :userId',
                'postId = :postId',
                'adopt = :adopt',
                'threadId = :threadId',
            ),
        );

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。