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
647 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;
650 eleazar 8
use LeadersLinked\Model\RecruitmentSelectionVacancy;
647 efrain 9
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10
use Laminas\Paginator\Paginator;
11
use Laminas\Db\ResultSet\HydratingResultSet;
12
use Laminas\Paginator\Adapter\DbSelect;
13
 
14
 
15
class RecruitmentSelectionVacancyMapper extends MapperCommon
16
{
3454 efrain 17
    const _TABLE = 'tbl_recruitment_selection_vacancies';
647 efrain 18
 
19
    /**
20
     *
3454 efrain 21
     * @var RecruitmentSelectionVacancyMapper
647 efrain 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 RecruitmentSelectionVacancyMapper
38
     */
39
    public static function getInstance($adapter)
40
    {
41
        if(self::$_instance == null) {
42
            self::$_instance = new RecruitmentSelectionVacancyMapper($adapter);
43
        }
44
        return self::$_instance;
45
    }
46
 
47
    /**
48
     *
49
     * @param int $id
1893 efrain 50
     * @return RecruitmentSelectionVacancy
647 efrain 51
     */
52
    public function fetchOne($id)
53
    {
650 eleazar 54
        $prototype = new RecruitmentSelectionVacancy();
647 efrain 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
1893 efrain 66
     * @return RecruitmentSelectionVacancy
647 efrain 67
     */
68
    public function fetchOneByUuid($uuid)
69
    {
650 eleazar 70
        $prototype = new RecruitmentSelectionVacancy();
647 efrain 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
1893 efrain 81
     * @return RecruitmentSelectionVacancy
647 efrain 82
     */
83
    public function fetchAllByCompanyId($company_id)
84
    {
650 eleazar 85
        $prototype = new RecruitmentSelectionVacancy();
647 efrain 86
 
87
        $select = $this->sql->select(self::_TABLE);
88
        $select->where->equalTo('company_id', $company_id);
5050 efrain 89
        $select->order('name');
90
 
91
        return $this->executeFetchAllObject($select, $prototype);
92
    }
93
 
94
    /**
95
     *
96
     * @param int $company_id
97
     * @return RecruitmentSelectionVacancy
98
     */
99
    public function fetchAllActiveByCompanyId($company_id)
100
    {
101
        $prototype = new RecruitmentSelectionVacancy();
102
 
103
        $select = $this->sql->select(self::_TABLE);
104
        $select->where->equalTo('company_id', $company_id);
1998 eleazar 105
        $select->where->equalTo('status', RecruitmentSelectionVacancy::STATUS_ACTIVE);
647 efrain 106
        $select->order('name');
107
 
108
        return $this->executeFetchAllObject($select, $prototype);
109
    }
5050 efrain 110
 
992 eleazar 111
 
647 efrain 112
 
113
    /**
114
     *
4776 efrain 115
     * @param RecruitmentSelectionVacancy $record
647 efrain 116
     * @return boolean
117
     */
4776 efrain 118
    public function insert($record)
647 efrain 119
    {
120
        $hydrator = new ObjectPropertyHydrator();
4776 efrain 121
        $values = $hydrator->extract($record);
647 efrain 122
        $values = $this->removeEmpty($values);
123
 
124
        $insert = $this->sql->insert(self::_TABLE);
125
        $insert->values($values);
126
 
127
        $result = $this->executeInsert($insert);
128
        if($result) {
4776 efrain 129
            $record->id = $this->lastInsertId;
647 efrain 130
        }
131
        return $result;
132
    }
133
 
134
    /**
135
     *
4776 efrain 136
     * @param RecruitmentSelectionVacancy $record
647 efrain 137
     * @return boolean
138
     */
4776 efrain 139
    public function update($record)
647 efrain 140
    {
141
        $hydrator = new ObjectPropertyHydrator();
4776 efrain 142
        $values = $hydrator->extract($record);
647 efrain 143
        $values = $this->removeEmpty($values);
144
 
145
        $update = $this->sql->update(self::_TABLE);
146
        $update->set($values);
4776 efrain 147
        $update->where->equalTo('id', $record->id);
647 efrain 148
        return $this->executeUpdate($update);
149
    }
150
 
151
    /**
152
     *
4776 efrain 153
     * @param int $id
647 efrain 154
     * @return boolean
155
     */
4776 efrain 156
    public function delete($id)
647 efrain 157
    {
158
        $delete = $this->sql->delete(self::_TABLE);
4776 efrain 159
        $delete->where->equalTo('id', $id);
647 efrain 160
 
161
        return $this->executeDelete($delete);
162
    }
163
 
164
 
165
    /**
166
     *
4776 efrain 167
 
647 efrain 168
    public function fetchAllDataTableByCompanyId($company_id, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
169
    {
650 eleazar 170
        $prototype = new RecruitmentSelectionVacancy();
647 efrain 171
        $select = $this->sql->select(self::_TABLE);
172
        $select->where->equalTo('company_id', $company_id);
173
 
174
        if($search) {
175
            $select->where->like('name', '%' . $search . '%');
176
        }
177
        $select->order($order_field . ' ' . $order_direction);
178
 
179
        //echo $select->getSqlString($this->adapter->platform); exit;
180
 
181
        $hydrator   = new ObjectPropertyHydrator();
182
        $resultset  = new HydratingResultSet($hydrator, $prototype);
183
 
184
        $adapter = new DbSelect($select, $this->sql, $resultset);
185
        $paginator = new Paginator($adapter);
186
        $paginator->setItemCountPerPage($records_per_page);
187
        $paginator->setCurrentPageNumber($page);
188
 
189
 
190
        return $paginator;
4776 efrain 191
    }*/
647 efrain 192
 
193
 
194
}