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\OrganizationalClimateLocation;
14
 
15
 
16
class OrganizationalClimateLocationMapper extends MapperCommon
17
{
18
    const _TABLE = 'tbl_organizational_climate_location';
19
 
20
    /**
21
     *
22
     * @var OrganizationalClimateMapper
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 OrganizationalClimateLocationMapper
39
     */
40
    public static function getInstance($adapter)
41
    {
42
        if(self::$_instance == null) {
43
            self::$_instance = new OrganizationalClimateLocationMapper($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
     *
1648 eleazar 81
     * @param int $organizationalClimate_id
1602 eleazar 82
     * @return OrganizationalClimate
83
     */
1648 eleazar 84
    public function fetchAllBySurveyId($organizationalClimate_id)
1602 eleazar 85
    {
86
        $prototype = new OrganizationalClimateLocation();
87
 
88
        $select = $this->sql->select(self::_TABLE);
1648 eleazar 89
        $select->where->equalTo('organizationalClimate_id', $organizationalClimate_id);
1602 eleazar 90
        $select->order('id');
91
 
92
        return $this->executeFetchOneObject($select, $prototype);
93
    }
94
 
95
 
96
    /**
97
     *
98
     * @param OrganizationalClimateForm $form
99
     * @return boolean
100
     */
101
    public function insert($form)
102
    {
103
        $hydrator = new ObjectPropertyHydrator();
104
        $values = $hydrator->extract($form);
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
        $result = $this->executeInsert($insert);
113
        if($result) {
114
            $form->id = $this->lastInsertId;
115
        }
116
        return $result;
117
    }
118
 
119
    /**
120
     *
121
     * @param OrganizationalClimateForm $form
122
     * @return boolean
123
     */
124
    public function update($form)
125
    {
126
        $hydrator = new ObjectPropertyHydrator();
127
        $values = $hydrator->extract($form);
128
        $values = $this->removeEmpty($values);
129
 
130
        $update = $this->sql->update(self::_TABLE);
131
        $update->set($values);
132
        $update->where->equalTo('id', $form->id);
133
 
134
        return $this->executeUpdate($update);
135
    }
136
 
137
    /**
138
     *
139
     * @param int $form_id
140
     * @return boolean
141
     */
1648 eleazar 142
    public function deleteBySurevy($organizationalClimate_id)
1602 eleazar 143
    {
144
        $delete = $this->sql->delete(self::_TABLE);
1648 eleazar 145
        $delete->where->equalTo('organizationalClimate_id', $organizationalClimate_id);
1602 eleazar 146
 
147
        return $this->executeDelete($delete);
148
    }
149
 
150
 
151
 
152
 
153
 
154
}