Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1602 eleazar 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\OrganizationalClimate;
9
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10
use Laminas\Paginator\Paginator;
11
use Laminas\Db\ResultSet\HydratingResultSet;
12
use Laminas\Paginator\Adapter\DbSelect;
13
use LeadersLinked\Model\OrganizationalClimateJobDescription;
14
 
15
 
16
class OrganizationalClimateJobDescriptionMapper extends MapperCommon
17
{
18
    const _TABLE = 'tbl_organizational_climate_job_description';
19
 
20
    /**
21
     *
22
     * @var OrganizationalClimateJobDescriptionMapper
23
     */
24
    private static $_instance;
25
 
26
    /**
27
     *
28
     * @param AdapterInterface $adapter
29
     */
30
    private function __construct($adapter)
31
    {
32
        parent::__construct($adapter);
33
    }
34
 
35
    /**
36
     *
37
     * @param AdapterInterface $adapter
38
     * @return OrganizationalClimateJobDescriptionMapper
39
     */
40
    public static function getInstance($adapter)
41
    {
42
        if(self::$_instance == null) {
43
            self::$_instance = new OrganizationalClimateJobDescriptionMapper($adapter);
44
        }
45
        return self::$_instance;
46
    }
47
 
48
    /**
49
     *
50
     * @param int $id
51
     * @return OrganizationalClimate
52
     */
53
    public function fetchOne($id)
54
    {
55
        $prototype = new OrganizationalClimate();
56
 
57
        $select = $this->sql->select(self::_TABLE);
58
        $select->where->equalTo('id', $id);
59
 
60
        return $this->executeFetchOneObject($select, $prototype);
61
    }
62
 
63
 
64
    /**
65
     *
66
     * @param int $uuid
67
     * @return OrganizationalClimate
68
     */
69
    public function fetchOneByUuid($uuid)
70
    {
71
        $prototype = new OrganizationalClimate();
72
        $select = $this->sql->select(self::_TABLE);
73
        $select->where->equalTo('uuid', $uuid);
74
 
75
        return $this->executeFetchOneObject($select, $prototype);
76
    }
77
 
78
 
79
    /**
80
     *
2176 efrain 81
     * @param int $organizational_climate_id
1602 eleazar 82
     * @return OrganizationalClimate
83
     */
2176 efrain 84
    public function fetchAllBySurveyId($organizational_climate_id)
1602 eleazar 85
    {
86
        $prototype = new OrganizationalClimateJobDescription();
87
 
88
        $select = $this->sql->select(self::_TABLE);
2176 efrain 89
        $select->where->equalTo('organizational_climate_id', $organizational_climate_id);
1602 eleazar 90
        $select->order('id');
91
 
92
        return $this->executeFetchAllObject($select, $prototype);
93
    }
94
 
95
 
96
    /**
97
     *
98
     * @param OrganizationalClimateJobDescription $record
99
     * @return boolean
100
     */
101
    public function insert($record)
102
    {
103
        $hydrator = new ObjectPropertyHydrator();
104
        $values = $hydrator->extract($record);
105
        $values = $this->removeEmpty($values);
106
 
107
        $insert = $this->sql->insert(self::_TABLE);
108
        $insert->values($values);
109
 
110
        //echo $insert->getSqlString($this->adapter->platform); exit;
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 SurveyForm $form
124
     * @return boolean
125
     */
126
    public function update($form)
127
    {
128
        $hydrator = new ObjectPropertyHydrator();
129
        $values = $hydrator->extract($form);
130
        $values = $this->removeEmpty($values);
131
 
132
        $update = $this->sql->update(self::_TABLE);
133
        $update->set($values);
134
        $update->where->equalTo('id', $form->id);
135
 
136
        return $this->executeUpdate($update);
137
    }
138
 
139
    /**
140
     *
141
     * @param int $form_id
142
     * @return boolean
143
     */
2176 efrain 144
    public function deleteBySurevy($organizational_climate_id)
1602 eleazar 145
    {
146
        $delete = $this->sql->delete(self::_TABLE);
2176 efrain 147
        $delete->where->equalTo('organizational_climate_id', $organizational_climate_id);
1602 eleazar 148
 
149
        return $this->executeDelete($delete);
150
    }
151
 
152
 
153
 
154
 
155
 
156
}