Proyectos de Subversion LeadersLinked - Services

Rev

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

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