4113 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Mapper;
|
|
|
6 |
|
|
|
7 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
8 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
|
|
9 |
|
|
|
10 |
use LeadersLinked\Model\JobDescriptionCompetencyBehavior;
|
|
|
11 |
use LeadersLinked\Mapper\Common\MapperCommon;
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
class JobDescriptionCompetencyBehaviorMapper extends MapperCommon
|
|
|
16 |
{
|
|
|
17 |
const _TABLE = 'tbl_job_description_competency_behaviors';
|
|
|
18 |
|
|
|
19 |
|
|
|
20 |
/**
|
|
|
21 |
*
|
|
|
22 |
* @var JobDescriptionCompetencyBehaviorMapper
|
|
|
23 |
*/
|
|
|
24 |
private static $_instance;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
*
|
|
|
28 |
* @param AdapterInterface $adapter
|
|
|
29 |
*/
|
|
|
30 |
private function __construct($adapter)
|
|
|
31 |
{
|
|
|
32 |
parent::__construct($adapter);
|
|
|
33 |
}
|
|
|
34 |
|
|
|
35 |
/**
|
|
|
36 |
*
|
|
|
37 |
* @param AdapterInterface $adapter
|
|
|
38 |
* @return JobDescriptionCompetencyBehaviorMapper
|
|
|
39 |
*/
|
|
|
40 |
public static function getInstance($adapter)
|
|
|
41 |
{
|
|
|
42 |
if(self::$_instance == null) {
|
|
|
43 |
self::$_instance = new JobDescriptionCompetencyBehaviorMapper($adapter);
|
|
|
44 |
}
|
|
|
45 |
return self::$_instance;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
/**
|
|
|
50 |
*
|
|
|
51 |
* @param int $id
|
|
|
52 |
* @return JobDescriptionCompetencyBehavior
|
|
|
53 |
*/
|
|
|
54 |
public function fetchOne($id)
|
|
|
55 |
{
|
|
|
56 |
$select = $this->sql->select(self::_TABLE);
|
|
|
57 |
$select->where->equalTo('id', $id);
|
|
|
58 |
$select->limit(1);
|
|
|
59 |
|
|
|
60 |
$prototype = new JobDescriptionCompetencyBehavior();
|
|
|
61 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
4268 |
efrain |
66 |
|
4113 |
efrain |
67 |
/**
|
|
|
68 |
*
|
|
|
69 |
* @param int $job_description_id
|
|
|
70 |
* @param int $competency_id
|
|
|
71 |
* @param int $behavior_id
|
|
|
72 |
* @return JobDescriptionCompetencyBehavior
|
|
|
73 |
*/
|
4268 |
efrain |
74 |
public function fetchOneByJobDescriptionIdAndCompetencyIdAndBehaviorId($job_description_id, $competency_id, $behavior_id)
|
4113 |
efrain |
75 |
{
|
|
|
76 |
$select = $this->sql->select(self::_TABLE);
|
|
|
77 |
$select->where->equalTo('job_description_id', $job_description_id);
|
|
|
78 |
$select->where->equalTo('behavior_id', $behavior_id);
|
|
|
79 |
$select->where->equalTo('competency_id', $competency_id);
|
|
|
80 |
$select->limit(1);
|
|
|
81 |
|
|
|
82 |
$prototype = new JobDescriptionCompetencyBehavior();
|
|
|
83 |
return $this->executeFetchOneObject($select, $prototype);
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
/**
|
|
|
87 |
*
|
|
|
88 |
* @param int $job_description_id
|
|
|
89 |
* @return JobDescriptionCompetencyBehavior[]
|
|
|
90 |
*/
|
|
|
91 |
public function fetchAllByJobDescriptionId($job_description_id)
|
|
|
92 |
{
|
|
|
93 |
$select = $this->sql->select(self::_TABLE);
|
|
|
94 |
$select->where->equalTo('job_description_id', $job_description_id);
|
|
|
95 |
|
|
|
96 |
$prototype = new JobDescriptionCompetencyBehavior();
|
|
|
97 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
98 |
}
|
|
|
99 |
|
|
|
100 |
/**
|
|
|
101 |
*
|
|
|
102 |
* @param int $job_description_id
|
|
|
103 |
* @param int $competency_id
|
|
|
104 |
* @return JobDescriptionCompetencyBehavior[]
|
|
|
105 |
*/
|
|
|
106 |
public function fetchAllByJobDescriptionIdAndCompetencyId($job_description_id, $competency_id)
|
|
|
107 |
{
|
|
|
108 |
$select = $this->sql->select(self::_TABLE);
|
|
|
109 |
$select->where->equalTo('job_description_id', $job_description_id);
|
|
|
110 |
$select->where->equalTo('competency_id', $competency_id);
|
|
|
111 |
|
|
|
112 |
$prototype = new JobDescriptionCompetencyBehavior();
|
|
|
113 |
return $this->executeFetchAllObject($select, $prototype);
|
|
|
114 |
}
|
|
|
115 |
|
|
|
116 |
/**
|
|
|
117 |
*
|
|
|
118 |
* @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
|
|
|
119 |
* @return boolean
|
|
|
120 |
*/
|
|
|
121 |
public function insert($jobDescriptionCompetencyBehavior)
|
|
|
122 |
{
|
|
|
123 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
124 |
$values = $hydrator->extract($jobDescriptionCompetencyBehavior);
|
|
|
125 |
$values = $this->removeEmpty($values);
|
|
|
126 |
|
|
|
127 |
$insert = $this->sql->insert(self::_TABLE);
|
|
|
128 |
$insert->values($values);
|
|
|
129 |
|
|
|
130 |
//echo $insert->getSqlString($this->adapter->platform); exit;
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
$result = $this->executeInsert($insert);
|
|
|
134 |
if($result) {
|
|
|
135 |
$jobDescriptionCompetencyBehavior->id = $this->getLastInsertId();
|
|
|
136 |
}
|
|
|
137 |
return $result;
|
|
|
138 |
|
|
|
139 |
}
|
|
|
140 |
|
|
|
141 |
/**
|
|
|
142 |
*
|
|
|
143 |
* @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
|
|
|
144 |
* @return boolean
|
|
|
145 |
*/
|
|
|
146 |
public function update($jobDescriptionCompetencyBehavior)
|
|
|
147 |
{
|
|
|
148 |
$hydrator = new ObjectPropertyHydrator();
|
|
|
149 |
$values = $hydrator->extract($jobDescriptionCompetencyBehavior);
|
|
|
150 |
$values = $this->removeEmpty($values);
|
|
|
151 |
|
|
|
152 |
$update = $this->sql->update(self::_TABLE);
|
|
|
153 |
$update->set($values);
|
|
|
154 |
$update->where->equalTo('id', $jobDescriptionCompetencyBehavior->id);
|
|
|
155 |
|
|
|
156 |
return $this->executeUpdate($update);
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
/**
|
|
|
160 |
*
|
|
|
161 |
* @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
|
|
|
162 |
* @return boolean
|
|
|
163 |
*/
|
|
|
164 |
public function delete($jobDescriptionCompetencyBehavior)
|
|
|
165 |
{
|
|
|
166 |
$delete = $this->sql->delete(self::_TABLE);
|
|
|
167 |
$delete->where->equalTo('id', $jobDescriptionCompetencyBehavior->id);
|
|
|
168 |
|
|
|
169 |
return $this->executeDelete($delete);
|
|
|
170 |
|
|
|
171 |
}
|
|
|
172 |
|
|
|
173 |
/**
|
|
|
174 |
*
|
|
|
175 |
* @param int $job_description_id
|
|
|
176 |
* @return boolean
|
|
|
177 |
*/
|
|
|
178 |
public function deleteAllBJobDescriptionId($job_description_id)
|
|
|
179 |
{
|
|
|
180 |
$delete = $this->sql->delete(self::_TABLE);
|
|
|
181 |
$delete->where->equalTo('job_description_id', $job_description_id);
|
|
|
182 |
|
|
|
183 |
return $this->executeDelete($delete);
|
|
|
184 |
|
|
|
185 |
}
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
}
|