1
0
mirror of https://gitee.com/koogua/course-tencent-cloud.git synced 2025-06-23 03:50:56 +08:00
course-tencent-cloud/app/Repos/CourseTopic.php
2020-04-03 19:20:46 +08:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Repos;
use App\Models\CourseTopic as CourseTopicModel;
use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Resultset;
use Phalcon\Mvc\Model\ResultsetInterface;
class CourseTopic extends Repository
{
/**
* @param int $courseId
* @param int $topicId
* @return CourseTopicModel|Model|bool
*/
public function findCourseTopic($courseId, $topicId)
{
return CourseTopicModel::findFirst([
'conditions' => 'course_id = :course_id: AND topic_id = :topic_id:',
'bind' => ['course_id' => $courseId, 'topic_id' => $topicId],
]);
}
/**
* @param array $topicIds
* @return ResultsetInterface|Resultset|CourseTopicModel[]
*/
public function findByTopicIds($topicIds)
{
return CourseTopicModel::query()
->inWhere('topic_id', $topicIds)
->execute();
}
/**
* @param array $courseIds
* @return ResultsetInterface|Resultset|CourseTopicModel[]
*/
public function findByCourseIds($courseIds)
{
return CourseTopicModel::query()
->inWhere('course_id', $courseIds)
->execute();
}
}