Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 607 | | Comparar con el anterior | Ultima modificación | Ver Log |

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