mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-26 04:21:27 +08:00
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Repos;
|
|
|
|
use App\Models\ArticleTag as ArticleTagModel;
|
|
use Phalcon\Mvc\Model;
|
|
use Phalcon\Mvc\Model\Resultset;
|
|
use Phalcon\Mvc\Model\ResultsetInterface;
|
|
|
|
class ArticleTag extends Repository
|
|
{
|
|
|
|
/**
|
|
* @param int $articleId
|
|
* @param int $tagId
|
|
* @return ArticleTagModel|Model|bool
|
|
*/
|
|
public function findArticleTag($articleId, $tagId)
|
|
{
|
|
return ArticleTagModel::findFirst([
|
|
'conditions' => 'article_id = :article_id: AND tag_id = :tag_id:',
|
|
'bind' => ['article_id' => $articleId, 'tag_id' => $tagId],
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* @param array $tagIds
|
|
* @return ResultsetInterface|Resultset|ArticleTagModel[]
|
|
*/
|
|
public function findByTagIds($tagIds)
|
|
{
|
|
return ArticleTagModel::query()
|
|
->inWhere('tag_id', $tagIds)
|
|
->execute();
|
|
}
|
|
|
|
/**
|
|
* @param array $articleIds
|
|
* @return ResultsetInterface|Resultset|ArticleTagModel[]
|
|
*/
|
|
public function findByArticleIds($articleIds)
|
|
{
|
|
return ArticleTagModel::query()
|
|
->inWhere('article_id', $articleIds)
|
|
->execute();
|
|
}
|
|
|
|
}
|