Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 192 | Rev 526 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
192 efrain 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\JobDescriptionCompetency;
16
use LeadersLinked\Mapper\Common\MapperCommon;
17
use Laminas\Hydrator\ArraySerializableHydrator;
18
 
19
 
20
 
21
class JobDescriptionCompetencyMapper extends MapperCommon
22
{
23
    const _TABLE = 'tbl_job_description_competencies';
24
 
25
 
26
    /**
27
     *
28
     * @var JobDescriptionCompetencyMapper
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 JobDescriptionCompetencyMapper
45
     */
46
    public static function getInstance($adapter)
47
    {
48
        if(self::$_instance == null) {
49
            self::$_instance = new JobDescriptionCompetencyMapper($adapter);
50
        }
51
        return self::$_instance;
52
    }
53
 
54
 
55
    /**
56
     *
57
     * @param int $id
58
     * @return JobDescriptionCompetency
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 JobDescriptionCompetency();
67
        return $this->executeFetchOneObject($select, $prototype);
68
    }
69
 
70
 
71
    /**
72
     *
73
     * @param int $job_description_id
74
     * @param int $competency_id
75
     * @return JobDescriptionCompetency
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 JobDescriptionCompetency();
85
        return $this->executeFetchOneObject($select, $prototype);
86
    }
87
 
88
    /**
89
     *
525 geraldo 90
     * @param int $job_description_id
91
     * @param int $competency_id
92
     * @return JobDescriptionCompetency
93
     */
94
    public function fetchByJobDescriptionIdAndCompetencyId($job_description_id, $competency_id)
95
    {
96
        $select = $this->sql->select(self::_TABLE);
97
        $select->where->equalTo('job_description_id', $job_description_id);
98
        $select->where->equalTo('competency_id', $competency_id);
99
        $select->limit(1);
100
 
101
        $prototype = new JobDescriptionCompetency();
102
        return $this->executeFetchOneObject($select, $prototype);
103
    }
104
 
105
    /**
106
     *
192 efrain 107
     * @param JobDescriptionCompetency $jobDescriptionCompetency
108
     * @return boolean
109
     */
110
    public function insert($jobDescriptionCompetency)
111
    {
112
        $hydrator = new ObjectPropertyHydrator();
113
        $values = $hydrator->extract($jobDescriptionCompetency);
114
        $values = $this->removeEmpty($values);
115
 
116
        $insert = $this->sql->insert(self::_TABLE);
117
        $insert->values($values);
118
 
119
        //echo $insert->getSqlString($this->adapter->platform); exit;
120
 
121
 
122
        $result = $this->executeInsert($insert);
123
        if($result) {
124
            $jobDescriptionCompetency->id = $this->getLastInsertId();
125
        }
126
        return $result;
127
 
128
    }
129
 
130
    /**
131
     *
132
     * @param JobDescriptionCompetency $jobDescriptionCompetency
133
     * @return boolean
134
     */
135
    public function update($jobDescriptionCompetency)
136
    {
137
        $hydrator = new ObjectPropertyHydrator();
138
        $values = $hydrator->extract($jobDescriptionCompetency);
139
        $values = $this->removeEmpty($values);
140
 
141
        $update = $this->sql->update(self::_TABLE);
142
        $update->set($values);
143
        $update->where->equalTo('id', $jobDescriptionCompetency->id);
144
 
145
        return $this->executeUpdate($update);
146
    }
147
 
148
    /**
149
     *
150
     * @param JobDescriptionCompetency $jobDescriptionCompetency
151
     * @return boolean
152
     */
153
    public function delete($jobDescriptionCompetency)
154
    {
155
        $delete = $this->sql->delete(self::_TABLE);
156
        $delete->where->equalTo('id', $jobDescriptionCompetency->id);
157
 
158
        return $this->executeDelete($delete);
159
 
160
    }
161
 
162
    /**
163
     *
164
     * @param int $job_description_id
165
     * @return boolean
166
     */
167
    public function deleteAllBJobDescriptionId($job_description_id)
168
    {
169
        $delete = $this->sql->delete(self::_TABLE);
170
        $delete->where->equalTo('job_description_id', $job_description_id);
171
 
172
        return $this->executeDelete($delete);
173
 
174
    }
175
 
176
 
177
 
178
 
179
}