Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7134 efrain 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Mapper;
5
 
6
use LeadersLinked\Mapper\Common\MapperCommon;
7
use Laminas\Db\Adapter\AdapterInterface;
8
use LeadersLinked\Model\KnowledgeAreaCategory;
9
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10
use LeadersLinked\Model\KnowledgeAreaCategoryJobDescription;
11
 
12
 
13
class KnowledgeAreaCategoryJobDescriptionMapper extends MapperCommon
14
{
15
    const _TABLE = 'tbl_knowledge_area_category_jobs_description';
16
 
17
    /**
18
     *
19
     * @var KnowledgeAreaCategoryJobDescriptionMapper
20
     */
21
    private static $_instance;
22
 
23
    /**
24
     *
25
     * @param AdapterInterface $adapter
26
     */
27
    private function __construct($adapter)
28
    {
29
        parent::__construct($adapter);
30
    }
31
 
32
    /**
33
     *
34
     * @param AdapterInterface $adapter
35
     * @return KnowledgeAreaCategoryJobDescriptionMapper
36
     */
37
    public static function getInstance($adapter)
38
    {
39
        if(self::$_instance == null) {
40
            self::$_instance = new KnowledgeAreaCategoryJobDescriptionMapper($adapter);
41
        }
42
        return self::$_instance;
43
    }
44
 
45
    /**
46
     *
47
     * @param int $category_id
48
     * @param int $job_description_id
49
     * @return KnowledgeAreaCategoryJobDescription
50
     */
51
    public function fetchOneByCategoryIdAndJobDescriptionId($category_id, $job_description_id)
52
    {
53
 
54
        $select = $this->sql->select(self::_TABLE);
55
        $select->where->equalTo('category_id', $category_id);
56
        $select->where->equalTo('job_description_id', $job_description_id);
57
 
58
        //echo $select->getSqlString($this->adapter->platform);
59
 
60
        $prototype = new KnowledgeAreaCategoryJobDescription();
61
        return $this->executeFetchOneObject($select, $prototype);
62
    }
63
 
64
 
65
 
66
    /**
67
     *
68
     * @param
69
     * @return KnowledgeAreaCategoryJobDescription[]
70
     */
71
    public function fetchAllByJobDescriptionId($job_description_id)
72
    {
73
 
74
        $select = $this->sql->select(self::_TABLE);
75
        $select->where->equalTo('job_description_id', $job_description_id);
76
 
77
 
78
        $prototype = new KnowledgeAreaCategoryJobDescription();
79
        return $this->executeFetchAllObject($select, $prototype);
80
    }
81
 
82
 
83
    /**
84
     *
85
     * @param int $company_id
86
     * @param array $job_description_ids
87
     * @return KnowledgeAreaCategoryJobDescription[]
88
     */
89
    public function fetchAllByCompanyIdAndJobDescriptionIds($company_id, $job_description_ids)
90
    {
91
 
92
        $select = $this->sql->select(self::_TABLE);
93
        $select->where->equalTo('company_id', $company_id);
94
        $select->where->in('job_description_id', $job_description_ids);
95
 
96
 
97
        $prototype = new KnowledgeAreaCategoryJobDescription();
98
        return $this->executeFetchAllObject($select, $prototype);
99
    }
100
 
101
    /**
102
     *
103
     * @param array $job_description_ids
104
     * @return KnowledgeAreaCategoryJobDescription[]
105
     */
106
    public function fetchAllByJobDescriptionIds($job_description_ids)
107
    {
108
 
109
        $select = $this->sql->select(self::_TABLE);
110
        $select->where->in('job_description_id', $job_description_ids);
111
 
112
 
113
        $prototype = new KnowledgeAreaCategoryJobDescription();
114
        return $this->executeFetchAllObject($select, $prototype);
115
    }
116
 
117
 
118
 
119
    /**
120
     *
121
     * @param
122
     * @return KnowledgeAreaCategoryJobDescription[]
123
     */
124
    public function fetchAllByCategoryId($category_id)
125
    {
126
 
127
        $select = $this->sql->select(self::_TABLE);
128
        $select->where->equalTo('category_id', $category_id);
129
 
130
 
131
        $prototype = new KnowledgeAreaCategoryJobDescription();
132
        return $this->executeFetchAllObject($select, $prototype);
133
    }
134
 
135
    /**
136
     *
137
     * @param int $category_id
138
     * @return boolean
139
     */
140
    public function deleteAllByCategoryId($category_id)
141
    {
142
        $delete = $this->sql->delete(self::_TABLE);
143
        $delete->where->equalTo('category_id', $category_id);
144
 
145
        return $this->executeDelete($delete);
146
    }
147
 
148
    /**
149
     *
150
     * @param int $category_id
151
     * @param int $job_description_id
152
     * @return boolean
153
     */
154
    public function  deleteOneByCategoryIdAndUserId($category_id, $job_description_id)
155
    {
156
        $delete = $this->sql->delete(self::_TABLE);
157
        $delete->where->equalTo('category_id', $category_id);
158
        $delete->where->equalTo('job_description_id', $job_description_id);
159
 
160
        return $this->executeDelete($delete);
161
    }
162
 
163
 
164
    /**
165
     *
166
     * @param int $id
167
     * @return boolean
168
     */
169
    public function  delete($id)
170
    {
171
 
172
        $delete = $this->sql->delete(self::_TABLE);
173
        $delete->where->equalTo('id', $id);
174
 
175
        return $this->executeDelete($delete);
176
    }
177
 
178
    /**
179
     *
180
     * @param KnowledgeAreaCategory $record
181
     * @return boolean
182
     */
183
    public function insert($record) {
184
        $hydrator = new ObjectPropertyHydrator();
185
        $values = $hydrator->extract($record);
186
        $values = $this->removeEmpty($values);
187
 
188
        $insert = $this->sql->insert(self::_TABLE);
189
        $insert->values($values);
190
        $result = $this->executeInsert($insert);
191
        if($result) {
192
            $record->id = $this->lastInsertId;
193
        }
194
 
195
       return $result;
196
    }
197
 
198
 
199
 
200
    /**
201
     *
202
     * @param KnowledgeAreaCategory $record
203
     * @return boolean
204
     */
205
    public function update($record)
206
    {
207
        $hydrator = new ObjectPropertyHydrator();
208
        $values = $hydrator->extract($record);
209
        $values = $this->removeEmpty($values);
210
 
211
        $update = $this->sql->update(self::_TABLE);
212
        $update->set($values);
213
        $update->where->equalTo('id', $record->id);
214
 
215
 
216
        return $this->executeUpdate($update);
217
    }
218
}