Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3454 | Ir a la última revisión | | 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);
1998 eleazar 89
        $select->where->equalTo('status', RecruitmentSelectionVacancy::STATUS_ACTIVE);
647 efrain 90
        $select->order('name');
91
 
92
        return $this->executeFetchAllObject($select, $prototype);
93
    }
992 eleazar 94
 
647 efrain 95
 
96
    /**
97
     *
4776 efrain 98
     * @param RecruitmentSelectionVacancy $record
647 efrain 99
     * @return boolean
100
     */
4776 efrain 101
    public function insert($record)
647 efrain 102
    {
103
        $hydrator = new ObjectPropertyHydrator();
4776 efrain 104
        $values = $hydrator->extract($record);
647 efrain 105
        $values = $this->removeEmpty($values);
106
 
107
        $insert = $this->sql->insert(self::_TABLE);
108
        $insert->values($values);
109
 
110
        $result = $this->executeInsert($insert);
111
        if($result) {
4776 efrain 112
            $record->id = $this->lastInsertId;
647 efrain 113
        }
114
        return $result;
115
    }
116
 
117
    /**
118
     *
4776 efrain 119
     * @param RecruitmentSelectionVacancy $record
647 efrain 120
     * @return boolean
121
     */
4776 efrain 122
    public function update($record)
647 efrain 123
    {
124
        $hydrator = new ObjectPropertyHydrator();
4776 efrain 125
        $values = $hydrator->extract($record);
647 efrain 126
        $values = $this->removeEmpty($values);
127
 
128
        $update = $this->sql->update(self::_TABLE);
129
        $update->set($values);
4776 efrain 130
        $update->where->equalTo('id', $record->id);
647 efrain 131
        return $this->executeUpdate($update);
132
    }
133
 
134
    /**
135
     *
4776 efrain 136
     * @param int $id
647 efrain 137
     * @return boolean
138
     */
4776 efrain 139
    public function delete($id)
647 efrain 140
    {
141
        $delete = $this->sql->delete(self::_TABLE);
4776 efrain 142
        $delete->where->equalTo('id', $id);
647 efrain 143
 
144
        return $this->executeDelete($delete);
145
    }
146
 
147
 
148
    /**
149
     *
4776 efrain 150
 
647 efrain 151
    public function fetchAllDataTableByCompanyId($company_id, $search, $page = 1, $records_per_page = 10, $order_field= 'name', $order_direction = 'ASC')
152
    {
650 eleazar 153
        $prototype = new RecruitmentSelectionVacancy();
647 efrain 154
        $select = $this->sql->select(self::_TABLE);
155
        $select->where->equalTo('company_id', $company_id);
156
 
157
        if($search) {
158
            $select->where->like('name', '%' . $search . '%');
159
        }
160
        $select->order($order_field . ' ' . $order_direction);
161
 
162
        //echo $select->getSqlString($this->adapter->platform); exit;
163
 
164
        $hydrator   = new ObjectPropertyHydrator();
165
        $resultset  = new HydratingResultSet($hydrator, $prototype);
166
 
167
        $adapter = new DbSelect($select, $this->sql, $resultset);
168
        $paginator = new Paginator($adapter);
169
        $paginator->setItemCountPerPage($records_per_page);
170
        $paginator->setCurrentPageNumber($page);
171
 
172
 
173
        return $paginator;
4776 efrain 174
    }*/
647 efrain 175
 
176
 
177
}