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\CompanyPerformanceEvaluationTestBoth;
13
 
14
 
15
class CompanyPerformanceEvaluationTestBothMapper extends MapperCommon
16
{
17
    const _TABLE = 'tbl_company_performance_evaluation_tests_both';
18
 
19
    /**
20
     *
21
     * @var CompanyPerformanceEvaluationTestBothMapper
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 CompanyPerformanceEvaluationTestBothMapper
38
     */
39
    public static function getInstance($adapter)
40
    {
41
        if(self::$_instance == null) {
42
            self::$_instance = new CompanyPerformanceEvaluationTestBothMapper($adapter);
43
        }
44
        return self::$_instance;
45
    }
46
 
47
    /**
48
     *
49
     * @param int $id
50
     * @return CompanyPerformanceEvaluationTestBoth
51
     */
52
    public function fetchOne($id)
53
    {
54
        $prototype = new CompanyPerformanceEvaluationTestBoth();
55
 
56
        $select = $this->sql->select(self::_TABLE);
57
        $select->where->equalTo('id', $id);
58
 
59
        return $this->executeFetchOneObject($select, $prototype);
60
    }
61
 
62
 
1676 eleazar 63
    /**
64
    *
65
    * @param int $id
66
    * @return CompanyPerformanceEvaluationTestBoth
67
    */
68
    public function fetchOneByTestId($test_id)
69
    {
70
        $prototype = new CompanyPerformanceEvaluationTestBoth();
71
 
72
        $select = $this->sql->select(self::_TABLE);
73
        $select->where->equalTo('test_id', $test_id);
74
 
75
        return $this->executeFetchOneObject($select, $prototype);
76
    }
1670 eleazar 77
 
78
    /**
79
     *
80
     * @param int $uuid
81
     * @return CompanyPerformanceEvaluationTestBoth
82
     */
83
    public function fetchOneByUuid($uuid)
84
    {
85
        $prototype = new CompanyPerformanceEvaluationTestBoth();
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 CompanyPerformanceEvaluationTestBoth $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);
106
 
107
        $result = $this->executeInsert($insert);
108
        if($result) {
109
            $test->id = $this->lastInsertId;
110
        }
111
        return $result;
112
    }
113
 
114
    /**
115
     *
116
     * @param CompanyPerformanceEvaluationTestBoth $test
117
     * @return boolean
118
     */
119
    public function update($test)
120
    {
121
        $hydrator = new ObjectPropertyHydrator();
122
        $values = $hydrator->extract($test);
123
        $values = $this->removeEmpty($values);
124
 
125
        $update = $this->sql->update(self::_TABLE);
126
        $update->set($values);
127
        $update->where->equalTo('id', $test->id);
128
 
129
        return $this->executeUpdate($update);
130
    }
131
 
132
    /**
133
     *
134
     * @param CompanyPerformanceEvaluationTestBoth $test
135
     * @return boolean
136
     */
137
    public function delete($test)
138
    {
139
        $delete = $this->sql->delete(self::_TABLE);
140
        $delete->where->equalTo('id', $test->id);
141
 
142
        return $this->executeDelete($delete);
143
    }
144
 
145
 
146
 
147
 
148
 
149
 
150
}