Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Ir a la última revisión | | 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
 
62
 
63
    /**
64
     *
65
     * @param int $uuid
66
     * @return RecruitmentSelectionApplication
67
     */
68
    public function fetchOneByUuid($uuid)
69
    {
70
        $prototype = new RecruitmentSelectionApplication();
71
        $select = $this->sql->select(self::_TABLE);
72
        $select->where->equalTo('uuid', $uuid);
73
 
74
        return $this->executeFetchOneObject($select, $prototype);
75
    }
76
 
77
 
78
    /**
79
     *
80
     * @param int $company_id
81
     * @return RecruitmentSelectionApplication
82
     */
83
    public function fetchAllByCompanyId($company_id)
84
    {
85
        $prototype = new RecruitmentSelectionApplication();
86
 
87
        $select = $this->sql->select(self::_TABLE);
88
        $select->where->equalTo('company_id', $company_id);
89
 
90
 
91
        return $this->executeFetchAllObject($select, $prototype);
92
    }
93
 
94
     /**
95
     *
96
     * @param int $candidate_id
97
     * @return RecruitmentSelectionApplication
98
     */
99
    public function fetchAllByVacancyId($vacancy_id)
100
    {
101
        $prototype = new RecruitmentSelectionApplication();
102
 
103
        $select = $this->sql->select(self::_TABLE);
104
        $select->where->equalTo('vacancy_id', $vacancy_id);
105
        $select->order('first_name');
106
 
107
        return $this->executeFetchAllObject($select, $prototype);
108
    }
109
 
110
 
111
    /**
112
     *
113
     * @param RecruitmentSelectionApplication $record
114
     * @return boolean
115
     */
116
    public function insert($record)
117
    {
118
        $hydrator = new ObjectPropertyHydrator();
119
        $values = $hydrator->extract($record);
120
        $values = $this->removeEmpty($values);
121
 
122
        $insert = $this->sql->insert(self::_TABLE);
123
        $insert->values($values);
124
 
125
       // echo $insert->getSqlString($this->adapter->platform); exit;
126
 
127
        $result = $this->executeInsert($insert);
128
        if($result) {
129
            $record->id = $this->lastInsertId;
130
        }
131
        return $result;
132
    }
133
 
134
    /**
135
     *
136
     * @param RecruitmentSelectionApplication $record
137
     * @return boolean
138
     */
139
    public function update($record)
140
    {
141
        $hydrator = new ObjectPropertyHydrator();
142
        $values = $hydrator->extract($record);
143
        $values = $this->removeEmpty($values);
144
 
145
        $update = $this->sql->update(self::_TABLE);
146
        $update->set($values);
147
        $update->where->equalTo('id', $record->id);
148
 
149
        return $this->executeUpdate($update);
150
    }
151
 
152
    /**
153
     *
154
     * @param int $id
155
     * @return boolean
156
     */
157
    public function delete($id)
158
    {
159
        $delete = $this->sql->delete(self::_TABLE);
160
        $delete->where->equalTo('id', $id);
161
 
162
        return $this->executeDelete($delete);
163
    }
164
 
165
 
166
    /**
167
    public function fetchAllDataTableByVacancyId($vacancy_id, $search, $page = 1, $records_per_page = 10, $order_field= 'title', $order_direction = 'ASC')
168
    {
169
        $prototype = new RecruitmentSelectionApplication();
170
        $select = $this->sql->select(self::_TABLE);
171
        $select->where->equalTo('vacancy_id', $vacancy_id);
172
 
173
        if($search) {
174
            $select->where->like('name', '%' . $search . '%');
175
        }
176
        $select->order($order_field . ' ' . $order_direction);
177
 
178
        //echo $select->getSqlString($this->adapter->platform); exit;
179
 
180
        $hydrator   = new ObjectPropertyHydrator();
181
        $resultset  = new HydratingResultSet($hydrator, $prototype);
182
 
183
        $adapter = new DbSelect($select, $this->sql, $resultset);
184
        $paginator = new Paginator($adapter);
185
        $paginator->setItemCountPerPage($records_per_page);
186
        $paginator->setCurrentPageNumber($page);
187
 
188
 
189
        return $paginator;
190
    }
191
    */
192
 
193
 
194
}