Proyectos de Subversion LeadersLinked - Services

Rev

Ir a la última revisión | | 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\Model\RecruitmentSelectionCandidate;
9
use LeadersLinked\Model\RecruitmentSelectionVacancy;
10
use LeadersLinked\Model\RecruitmentSelectionInterview;
11
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
12
use Laminas\Paginator\Paginator;
13
use Laminas\Db\ResultSet\HydratingResultSet;
14
use Laminas\Paginator\Adapter\DbSelect;
15
 
16
 
17
class RecruitmentSelectionInterviewMapper extends MapperCommon
18
{
19
    const _TABLE = 'tbl_recruitment_selection_interviews';
20
 
21
    /**
22
     *
23
     * @var RecruitmentSelectionInterviewMapper
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 RecruitmentSelectionInterviewMapper
40
     */
41
    public static function getInstance($adapter)
42
    {
43
        if(self::$_instance == null) {
44
            self::$_instance = new RecruitmentSelectionInterviewMapper($adapter);
45
        }
46
        return self::$_instance;
47
    }
48
 
49
    /**
50
     *
51
     * @param int $id
52
     * @return RecruitmentSelectionInterview
53
     */
54
    public function fetchOne($id)
55
    {
56
        $prototype = new RecruitmentSelectionInterview();
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
     *
67
     * @param int $uuid
68
     * @return RecruitmentSelectionInterview
69
     */
70
    public function fetchOneByUuid($uuid)
71
    {
72
        $prototype = new RecruitmentSelectionInterview();
73
        $select = $this->sql->select(self::_TABLE);
74
        $select->where->equalTo('uuid', $uuid);
75
 
76
        return $this->executeFetchOneObject($select, $prototype);
77
    }
78
 
79
 
80
    /**
81
     *
82
     * @param int $vacancy_id
83
     * @return RecruitmentSelectionInterview[]
84
     */
85
    public function fetchAllByVacancyId($vacancy_id)
86
    {
87
        $prototype = new RecruitmentSelectionInterview();
88
 
89
        $select = $this->sql->select(self::_TABLE);
90
        $select->where->equalTo('vacancy_id', $vacancy_id);
91
 
92
        return $this->executeFetchAllObject($select, $prototype);
93
    }
94
 
95
 
96
 
97
 
98
    /**
99
     *
100
     * @param RecruitmentSelectionInterviewMapper $record
101
     * @return boolean
102
     */
103
    public function insert($record)
104
    {
105
        $hydrator = new ObjectPropertyHydrator();
106
        $values = $hydrator->extract($record);
107
        $values = $this->removeEmpty($values);
108
 
109
        $insert = $this->sql->insert(self::_TABLE);
110
        $insert->values($values);
111
 
112
       // echo $insert->getSqlString($this->adapter->platform); exit;
113
 
114
        $result = $this->executeInsert($insert);
115
        if($result) {
116
            $record->id = $this->lastInsertId;
117
        }
118
        return $result;
119
    }
120
 
121
    /**
122
     *
123
     * @param RecruitmentSelectionInterviewMapper $record
124
     * @return boolean
125
     */
126
    public function update($record)
127
    {
128
        $hydrator = new ObjectPropertyHydrator();
129
        $values = $hydrator->extract($record);
130
        $values = $this->removeEmpty($values);
131
 
132
        $update = $this->sql->update(self::_TABLE);
133
        $update->set($values);
134
        $update->where->equalTo('id', $record->id);
135
 
136
        return $this->executeUpdate($update);
137
    }
138
 
139
    /**
140
     *
141
     * @param int $record_id
142
     * @return boolean
143
     */
144
    public function delete($id)
145
    {
146
        $delete = $this->sql->delete(self::_TABLE);
147
        $delete->where->equalTo('id', $id);
148
 
149
        return $this->executeDelete($delete);
150
    }
151
 
152
 
153
    /*
154
    public function fetchAllDataTableByCompanyId($companyId, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
155
    {
156
        $prototype = new RecruitmentSelectionCandidate();
157
        $select = $this->sql->select(self::_TABLE);
158
        $select->where->equalTo('company_id', $companyId);
159
 
160
        if($search) {
161
            $select->where->like('name', '%' . $search . '%');
162
        }
163
        $select->order($order_field . ' ' . $order_direction);
164
 
165
        //echo $select->getSqlString($this->adapter->platform); exit;
166
 
167
        $hydrator   = new ObjectPropertyHydrator();
168
        $resultset  = new HydratingResultSet($hydrator, $prototype);
169
 
170
        $adapter = new DbSelect($select, $this->sql, $resultset);
171
        $paginator = new Paginator($adapter);
172
        $paginator->setItemCountPerPage($records_per_page);
173
        $paginator->setCurrentPageNumber($page);
174
 
175
 
176
        return $paginator;
177
    }*/
178
 
179
 
180
}