Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 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\CompanySelfEvaluationForm;
9
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10
 
11
 
12
class CompanySelfEvaluationFormMapper extends MapperCommon
13
{
14
    const _TABLE = 'tbl_company_self_evaluation_forms';
15
 
16
    /**
17
     *
18
     * @var CompanySelfEvaluationFormMapper
19
     */
20
    private static $_instance;
21
 
22
    /**
23
     *
24
     * @param AdapterInterface $adapter
25
     */
26
    private function __construct($adapter)
27
    {
28
        parent::__construct($adapter);
29
    }
30
 
31
    /**
32
     *
33
     * @param AdapterInterface $adapter
34
     * @return CompanySelfEvaluationFormMapper
35
     */
36
    public static function getInstance($adapter)
37
    {
38
        if(self::$_instance == null) {
39
            self::$_instance = new CompanySelfEvaluationFormMapper($adapter);
40
        }
41
        return self::$_instance;
42
    }
43
 
44
    /**
45
     *
46
     * @param int $id
47
     * @return CompanySelfEvaluationForm
48
     */
49
    public function fetchOne($id)
50
    {
51
        $prototype = new CompanySelfEvaluationForm();
52
 
53
        $select = $this->sql->select(self::_TABLE);
54
        $select->where->equalTo('id', $id);
55
 
56
        return $this->executeFetchOneObject($select, $prototype);
57
    }
58
 
59
 
60
    /**
61
     *
62
     * @param int $uuid
63
     * @return CompanySelfEvaluationForm
64
     */
65
    public function fetchOneByUuid($uuid)
66
    {
67
        $prototype = new CompanySelfEvaluationForm;
68
        $select = $this->sql->select(self::_TABLE);
69
        $select->where->equalTo('uuid', $uuid);
70
 
71
        return $this->executeFetchOneObject($select, $prototype);
72
    }
73
 
74
 
75
    /**
76
     *
77
     * @param CompanySelfEvaluationForm $form
78
     * @return boolean
79
     */
80
    public function insert($form)
81
    {
82
        $hydrator = new ObjectPropertyHydrator();
83
        $values = $hydrator->extract($form);
84
        $values = $this->removeEmpty($values);
85
 
86
        $insert = $this->sql->insert(self::_TABLE);
87
        $insert->values($values);
88
 
89
        $result = $this->executeInsert($insert);
90
        if($result) {
91
            $form->id = $this->lastInsertId;
92
        }
93
        return $result;
94
    }
95
 
96
    /**
97
     *
98
     * @param CompanySelfEvaluationForm $form
99
     * @return boolean
100
     */
101
    public function update($form)
102
    {
103
        $hydrator = new ObjectPropertyHydrator();
104
        $values = $hydrator->extract($form);
105
        $values = $this->removeEmpty($values);
106
 
107
        $update = $this->sql->update(self::_TABLE);
108
        $update->set($values);
109
        $update->where->equalTo('id', $form->id);
110
 
111
        return $this->executeUpdate($update);
112
    }
113
 
114
    /**
115
     *
116
     * @param CompanySelfEvaluationForm $form
117
     * @return boolean
118
     */
119
    public function delete($form)
120
    {
121
        $delete = $this->sql->delete(self::_TABLE);
122
        $delete->where->equalTo('id', $form->id);
123
 
124
        return $this->executeDelete($delete);
125
    }
126
 
127
 
128
}