Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1670 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\Hydrator\ObjectPropertyHydrator;
9
use Laminas\Paginator\Paginator;
10
use Laminas\Db\ResultSet\HydratingResultSet;
11
use Laminas\Paginator\Adapter\DbSelect;
12
use LeadersLinked\Model\CompanyPerformanceEvaluationTestSelf;
13
 
14
 
15
class CompanyPerformanceEvaluationTestSelfMapper extends MapperCommon
16
{
17
    const _TABLE = 'tbl_company_performance_evaluation_tests_self';
18
 
19
    /**
20
     *
21
     * @var CompanyPerformanceEvaluationTestSelfMapper
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 CompanyPerformanceEvaluationTestSelfMapper
38
     */
39
    public static function getInstance($adapter)
40
    {
41
        if(self::$_instance == null) {
42
            self::$_instance = new CompanyPerformanceEvaluationTestSelfMapper($adapter);
43
        }
44
        return self::$_instance;
45
    }
46
 
47
    /**
48
     *
49
     * @param int $id
50
     * @return CompanyPerformanceEvaluationTestSelf
51
     */
52
    public function fetchOne($id)
53
    {
54
        $prototype = new CompanyPerformanceEvaluationTestSelf();
55
 
56
        $select = $this->sql->select(self::_TABLE);
57
        $select->where->equalTo('id', $id);
58
 
59
        return $this->executeFetchOneObject($select, $prototype);
60
    }
61
 
1675 eleazar 62
     /**
63
     *
64
     * @param int $id
65
     * @return CompanyPerformanceEvaluationTestSelf
66
     */
67
    public function fetchOneByTestId($test_id)
68
    {
69
        $prototype = new CompanyPerformanceEvaluationTestSelf();
70
 
71
        $select = $this->sql->select(self::_TABLE);
72
        $select->where->equalTo('test_id', $test_id);
73
 
74
        return $this->executeFetchOneObject($select, $prototype);
75
    }
1670 eleazar 76
 
77
 
78
    /**
79
     *
80
     * @param int $uuid
81
     * @return CompanyPerformanceEvaluationTestSelf
82
     */
83
    public function fetchOneByUuid($uuid)
84
    {
85
        $prototype = new CompanyPerformanceEvaluationTestSelf();
86
        $select = $this->sql->select(self::_TABLE);
87
        $select->where->equalTo('uuid', $uuid);
88
 
89
        return $this->executeFetchOneObject($select, $prototype);
90
    }
91
 
92
 
93
    /**
94
     *
95
     * @param CompanyPerformanceEvaluationTestSelf $test
96
     * @return boolean
97
     */
98
    public function insert($test)
99
    {
100
        $hydrator = new ObjectPropertyHydrator();
101
        $values = $hydrator->extract($test);
102
        $values = $this->removeEmpty($values);
103
 
104
        $insert = $this->sql->insert(self::_TABLE);
105
        $insert->values($values);
1671 eleazar 106
 
1674 eleazar 107
       // echo $insert->getSqlString($this->adapter->platform); exit;
1670 eleazar 108
 
109
        $result = $this->executeInsert($insert);
110
        if($result) {
111
            $test->id = $this->lastInsertId;
112
        }
113
        return $result;
114
    }
115
 
116
    /**
117
     *
118
     * @param CompanyPerformanceEvaluationTestSelf $test
119
     * @return boolean
120
     */
121
    public function update($test)
122
    {
123
        $hydrator = new ObjectPropertyHydrator();
124
        $values = $hydrator->extract($test);
125
        $values = $this->removeEmpty($values);
126
 
127
        $update = $this->sql->update(self::_TABLE);
128
        $update->set($values);
129
        $update->where->equalTo('id', $test->id);
130
 
131
        return $this->executeUpdate($update);
132
    }
133
 
134
    /**
135
     *
136
     * @param CompanyPerformanceEvaluationTestSelf $test
137
     * @return boolean
138
     */
139
    public function delete($test)
140
    {
141
        $delete = $this->sql->delete(self::_TABLE);
142
        $delete->where->equalTo('id', $test->id);
143
 
144
        return $this->executeDelete($delete);
145
    }
146
 
147
 
148
 
149
 
150
 
151
 
152
}