Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev Autor Línea Nro. Línea
4776 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\Hydrator\ObjectPropertyHydrator;
9
use Laminas\Paginator\Paginator;
10
use Laminas\Db\ResultSet\HydratingResultSet;
11
use Laminas\Paginator\Adapter\DbSelect;
12
use LeadersLinked\Model\RecruitmentSelectionApplication;
13
 
14
 
15
class RecruitmentSelectionApplicationMapper extends MapperCommon
16
{
17
    const _TABLE = 'tbl_recruitment_selection_applications';
18
 
19
    /**
20
     *
21
     * @var RecruitmentSelectionApplicationMapper
22
     */
23
    private static $_instance;
24
 
25
    /**
26
     *
27
     * @param AdapterInterface $adapter
28
     */
29
    private function __construct($adapter)
30
    {
31
        parent::__construct($adapter);
32
    }
33
 
34
    /**
35
     *
36
     * @param AdapterInterface $adapter
37
     * @return RecruitmentSelectionApplicationMapper
38
     */
39
    public static function getInstance($adapter)
40
    {
41
        if(self::$_instance == null) {
42
            self::$_instance = new RecruitmentSelectionApplicationMapper($adapter);
43
        }
44
        return self::$_instance;
45
    }
46
 
47
    /**
48
     *
49
     * @param int $id
50
     * @return RecruitmentSelectionApplication
51
     */
52
    public function fetchOne($id)
53
    {
54
        $prototype = new RecruitmentSelectionApplication();
55
 
56
        $select = $this->sql->select(self::_TABLE);
57
        $select->where->equalTo('id', $id);
58
 
59
        return $this->executeFetchOneObject($select, $prototype);
60
    }
61
 
5050 efrain 62
    /**
63
     *
64
     * @param int $vacancy_id
65
     * @param int $candidate_id
66
     * @return RecruitmentSelectionApplication
67
     */
68
    public function fetchOneByVancancyIdAndCandidateId($vacancy_id, $candidate_id)
69
    {
70
 
71
        $select = $this->sql->select(self::_TABLE);
72
        $select->where->equalTo('vacancy_id', $vacancy_id);
73
        $select->where->equalTo('candidate_id', $candidate_id);
74
 
75
        $prototype = new RecruitmentSelectionApplication();
76
        return $this->executeFetchOneObject($select, $prototype);
77
    }
4776 efrain 78
 
5050 efrain 79
 
4776 efrain 80
    /**
81
     *
82
     * @param int $uuid
83
     * @return RecruitmentSelectionApplication
84
     */
85
    public function fetchOneByUuid($uuid)
86
    {
87
        $prototype = new RecruitmentSelectionApplication();
88
        $select = $this->sql->select(self::_TABLE);
89
        $select->where->equalTo('uuid', $uuid);
90
 
91
        return $this->executeFetchOneObject($select, $prototype);
92
    }
93
 
94
 
95
    /**
96
     *
97
     * @param int $company_id
98
     * @return RecruitmentSelectionApplication
99
     */
100
    public function fetchAllByCompanyId($company_id)
101
    {
102
        $prototype = new RecruitmentSelectionApplication();
103
 
104
        $select = $this->sql->select(self::_TABLE);
105
        $select->where->equalTo('company_id', $company_id);
106
 
107
 
108
        return $this->executeFetchAllObject($select, $prototype);
109
    }
110
 
111
     /**
112
     *
113
     * @param int $candidate_id
114
     * @return RecruitmentSelectionApplication
115
     */
116
    public function fetchAllByVacancyId($vacancy_id)
117
    {
118
        $prototype = new RecruitmentSelectionApplication();
119
 
120
        $select = $this->sql->select(self::_TABLE);
121
        $select->where->equalTo('vacancy_id', $vacancy_id);
122
        $select->order('first_name');
123
 
124
        return $this->executeFetchAllObject($select, $prototype);
125
    }
126
 
127
 
128
    /**
129
     *
130
     * @param RecruitmentSelectionApplication $record
131
     * @return boolean
132
     */
133
    public function insert($record)
134
    {
135
        $hydrator = new ObjectPropertyHydrator();
136
        $values = $hydrator->extract($record);
137
        $values = $this->removeEmpty($values);
138
 
139
        $insert = $this->sql->insert(self::_TABLE);
140
        $insert->values($values);
141
 
142
       // echo $insert->getSqlString($this->adapter->platform); exit;
143
 
144
        $result = $this->executeInsert($insert);
145
        if($result) {
146
            $record->id = $this->lastInsertId;
147
        }
148
        return $result;
149
    }
150
 
151
    /**
152
     *
153
     * @param RecruitmentSelectionApplication $record
154
     * @return boolean
155
     */
156
    public function update($record)
157
    {
158
        $hydrator = new ObjectPropertyHydrator();
159
        $values = $hydrator->extract($record);
160
        $values = $this->removeEmpty($values);
161
 
162
        $update = $this->sql->update(self::_TABLE);
163
        $update->set($values);
164
        $update->where->equalTo('id', $record->id);
165
 
166
        return $this->executeUpdate($update);
167
    }
168
 
169
    /**
170
     *
171
     * @param int $id
172
     * @return boolean
173
     */
174
    public function delete($id)
175
    {
176
        $delete = $this->sql->delete(self::_TABLE);
177
        $delete->where->equalTo('id', $id);
178
 
179
        return $this->executeDelete($delete);
180
    }
181
 
182
 
183
    /**
184
    public function fetchAllDataTableByVacancyId($vacancy_id, $search, $page = 1, $records_per_page = 10, $order_field= 'title', $order_direction = 'ASC')
185
    {
186
        $prototype = new RecruitmentSelectionApplication();
187
        $select = $this->sql->select(self::_TABLE);
188
        $select->where->equalTo('vacancy_id', $vacancy_id);
189
 
190
        if($search) {
191
            $select->where->like('name', '%' . $search . '%');
192
        }
193
        $select->order($order_field . ' ' . $order_direction);
194
 
195
        //echo $select->getSqlString($this->adapter->platform); exit;
196
 
197
        $hydrator   = new ObjectPropertyHydrator();
198
        $resultset  = new HydratingResultSet($hydrator, $prototype);
199
 
200
        $adapter = new DbSelect($select, $this->sql, $resultset);
201
        $paginator = new Paginator($adapter);
202
        $paginator->setItemCountPerPage($records_per_page);
203
        $paginator->setCurrentPageNumber($page);
204
 
205
 
206
        return $paginator;
207
    }
208
    */
209
 
210
 
211
}