| 5935 |
efrain |
1 |
<?php
|
|
|
2 |
declare(strict_types=1);
|
|
|
3 |
|
|
|
4 |
namespace LeadersLinked\Mapper;
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
use LeadersLinked\Mapper\Common\MapperCommon;
|
|
|
8 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
9 |
use LeadersLinked\Model\KnowledgeAreaCategoryContent;
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
class KnowledgeAreaCategoryContentMapper extends MapperCommon
|
|
|
13 |
{
|
|
|
14 |
const _TABLE = 'tbl_knowledge_area_category_content';
|
|
|
15 |
|
|
|
16 |
/**
|
|
|
17 |
*
|
|
|
18 |
* @var KnowledgeAreaCategoryContentMapper
|
|
|
19 |
*/
|
|
|
20 |
private static $_instance;
|
|
|
21 |
|
|
|
22 |
/**
|
|
|
23 |
*
|
|
|
24 |
* @param AdapterInterface $adapter
|
|
|
25 |
*/
|
|
|
26 |
private function __construct($adapter)
|
|
|
27 |
{
|
|
|
28 |
parent::__construct($adapter);
|
|
|
29 |
}
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
*
|
|
|
33 |
* @param AdapterInterface $adapter
|
|
|
34 |
* @return KnowledgeAreaCategoryContentMapper
|
|
|
35 |
*/
|
|
|
36 |
public static function getInstance($adapter)
|
|
|
37 |
{
|
|
|
38 |
if(self::$_instance == null) {
|
|
|
39 |
self::$_instance = new KnowledgeAreaCategoryContentMapper($adapter);
|
|
|
40 |
}
|
|
|
41 |
return self::$_instance;
|
|
|
42 |
}
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
*
|
|
|
46 |
* @param int $question_id
|
|
|
47 |
* @param int $category_id
|
|
|
48 |
* @return KnowledgeAreaCategoryContent
|
|
|
49 |
*/
|
|
|
50 |
public function fetchOneByQuestionIdAndCategoryId($question_id, $category_id )
|
|
|
51 |
{
|
|
|
52 |
|
|
|
53 |
$select = $this->sql->select(self::_TABLE);
|
|
|
54 |
$select->where->equalTo('category_id', $category_id);
|
|
|
55 |
$select->where->equalTo('question_id', $question_id);
|
|
|
56 |
|
|
|
57 |
$prototype = new KnowledgeAreaCategoryContent();
|
|
|
58 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
59 |
}
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
*
|
|
|
68 |
* @param
|
|
|
69 |
* @return KnowledgeAreaCategoryContent[]
|
|
|
70 |
*/
|
|
|
71 |
public function fetchAllByQuestionId($question_id)
|
|
|
72 |
{
|
|
|
73 |
|
|
|
74 |
$select = $this->sql->select(self::_TABLE);
|
|
|
75 |
$select->where->equalTo('question_id', $question_id);
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
$prototype = new KnowledgeAreaCategoryContent();
|
|
|
79 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
*
|
|
|
84 |
* @param int $question_id
|
|
|
85 |
* @param int $category_id
|
|
|
86 |
* @return boolean
|
|
|
87 |
*/
|
|
|
88 |
public function deleteByQuestionIdAndCategoryId($question_id, $category_id )
|
|
|
89 |
{
|
|
|
90 |
$delete = $this->sql->delete(self::_TABLE);
|
|
|
91 |
$delete->where->equalTo('category_id', $category_id);
|
|
|
92 |
$delete->where->equalTo('question_id', $question_id);
|
|
|
93 |
|
|
|
94 |
return $this->executeDelete($delete);
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
}
|