Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
    /**
66
     *
67
     * @param int $job_description_id
68
     * @param int $competency_id
69
     * @return JobDescriptionCompetencyBehavior
70
     */
71
    public function fetchOneByJobDescriptionIdAndCompetencyId($job_description_id, $competency_id)
72
    {
73
        $select = $this->sql->select(self::_TABLE);
74
        $select->where->equalTo('job_description_id', $job_description_id);
75
        $select->where->equalTo('competency_id', $competency_id);
76
        $select->limit(1);
77
 
78
        $prototype = new JobDescriptionCompetencyBehavior();
79
        return $this->executeFetchOneObject($select, $prototype);
80
    }
81
 
82
    /**
83
     *
84
     * @param int $job_description_id
85
     * @param int $competency_id
86
     * @param int $behavior_id
87
     * @return JobDescriptionCompetencyBehavior
88
     */
89
    public function fetchOneByBehavior($job_description_id, $competency_id, $behavior_id)
90
    {
91
        $select = $this->sql->select(self::_TABLE);
92
        $select->where->equalTo('job_description_id', $job_description_id);
93
        $select->where->equalTo('behavior_id', $behavior_id);
94
        $select->where->equalTo('competency_id', $competency_id);
95
        $select->limit(1);
96
 
97
        $prototype = new JobDescriptionCompetencyBehavior();
98
        return $this->executeFetchOneObject($select, $prototype);
99
    }
100
 
101
    /**
102
     *
103
     * @param int $job_description_id
104
     * @return JobDescriptionCompetencyBehavior[]
105
     */
106
    public function fetchAllByJobDescriptionId($job_description_id)
107
    {
108
        $select = $this->sql->select(self::_TABLE);
109
        $select->where->equalTo('job_description_id', $job_description_id);
110
 
111
        $prototype = new JobDescriptionCompetencyBehavior();
112
        return $this->executeFetchAllObject($select, $prototype);
113
    }
114
 
115
    /**
116
     *
117
     * @param int $job_description_id
118
     * @param int $competency_id
119
     * @return JobDescriptionCompetencyBehavior[]
120
     */
121
    public function fetchAllByJobDescriptionIdAndCompetencyId($job_description_id, $competency_id)
122
    {
123
        $select = $this->sql->select(self::_TABLE);
124
        $select->where->equalTo('job_description_id', $job_description_id);
125
        $select->where->equalTo('competency_id', $competency_id);
126
 
127
        $prototype = new JobDescriptionCompetencyBehavior();
128
        return $this->executeFetchAllObject($select, $prototype);
129
    }
130
 
131
    /**
132
     *
133
     * @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
134
     * @return boolean
135
     */
136
    public function insert($jobDescriptionCompetencyBehavior)
137
    {
138
        $hydrator = new ObjectPropertyHydrator();
139
        $values = $hydrator->extract($jobDescriptionCompetencyBehavior);
140
        $values = $this->removeEmpty($values);
141
 
142
        $insert = $this->sql->insert(self::_TABLE);
143
        $insert->values($values);
144
 
145
        //echo $insert->getSqlString($this->adapter->platform); exit;
146
 
147
 
148
        $result = $this->executeInsert($insert);
149
        if($result) {
150
            $jobDescriptionCompetencyBehavior->id = $this->getLastInsertId();
151
        }
152
        return $result;
153
 
154
    }
155
 
156
    /**
157
     *
158
     * @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
159
     * @return boolean
160
     */
161
    public function update($jobDescriptionCompetencyBehavior)
162
    {
163
        $hydrator = new ObjectPropertyHydrator();
164
        $values = $hydrator->extract($jobDescriptionCompetencyBehavior);
165
        $values = $this->removeEmpty($values);
166
 
167
        $update = $this->sql->update(self::_TABLE);
168
        $update->set($values);
169
        $update->where->equalTo('id', $jobDescriptionCompetencyBehavior->id);
170
 
171
        return $this->executeUpdate($update);
172
    }
173
 
174
    /**
175
     *
176
     * @param JobDescriptionCompetencyBehavior $jobDescriptionCompetencyBehavior
177
     * @return boolean
178
     */
179
    public function delete($jobDescriptionCompetencyBehavior)
180
    {
181
        $delete = $this->sql->delete(self::_TABLE);
182
        $delete->where->equalTo('id', $jobDescriptionCompetencyBehavior->id);
183
 
184
        return $this->executeDelete($delete);
185
 
186
    }
187
 
188
    /**
189
     *
190
     * @param int $job_description_id
191
     * @return boolean
192
     */
193
    public function deleteAllBJobDescriptionId($job_description_id)
194
    {
195
        $delete = $this->sql->delete(self::_TABLE);
196
        $delete->where->equalTo('job_description_id', $job_description_id);
197
 
198
        return $this->executeDelete($delete);
199
 
200
    }
201
 
202
 
203
 
204
 
205
}