Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
236 efrain 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\CompanySelfEvaluationFormUser;
13
 
14
 
15
class CompanySelfEvaluationFormUserMapper extends MapperCommon
16
{
17
    const _TABLE = 'tbl_company_self_evaluation_form_users';
18
 
19
    /**
20
     *
21
     * @var CompanySelfEvaluationFormUserMapper
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 CompanySelfEvaluationFormUserMapper
38
     */
39
    public static function getInstance($adapter)
40
    {
41
        if(self::$_instance == null) {
42
            self::$_instance = new CompanySelfEvaluationFormUserMapper($adapter);
43
        }
44
        return self::$_instance;
45
    }
46
 
47
 
48
    /**
49
     *
50
     * @param int $company_id
51
     * @param int $form_id
52
     * @return CompanySelfEvaluationFormUser[]
53
     */
54
    public function fetchAllByCompanyIdAndFormId($company_id, $form_id)
55
    {
56
        $prototype = new CompanySelfEvaluationFormUser();
57
 
58
        $select = $this->sql->select(self::_TABLE);
59
        $select->where->equalTo('company_id', $company_id);
60
        $select->where->equalTo('form_id', $form_id);
61
 
62
        return $this->executeFetchAllObject($select, $prototype);
63
    }
64
 
65
 
66
    /**
67
     *
68
     * @param int $company_id
69
     * @param int $form_id
70
     * @param int $user_id
71
     * @return CompanySelfEvaluationFormUser
72
     */
73
    public function fetchAllByCompanyIdAndFormIdAndUserId($company_id, $form_id, $user_id)
74
    {
75
        $prototype = new CompanySelfEvaluationFormUser();
76
 
77
        $select = $this->sql->select(self::_TABLE);
78
        $select->where->equalTo('company_id', $company_id);
79
        $select->where->equalTo('form_id', $form_id);
80
        $select->where->equalTo('user_id', $user_id);
81
 
82
 
83
        return $this->executeFetchOneObject($select, $prototype);
84
    }
85
 
86
 
87
    /**
88
     *
89
     * @param int $id
90
     * @return CompanySelfEvaluationFormUser
91
     */
92
    public function fetchOne($id)
93
    {
94
        $prototype = new CompanySelfEvaluationFormUser();
95
 
96
        $select = $this->sql->select(self::_TABLE);
97
        $select->where->equalTo('id', $id);
98
 
99
        return $this->executeFetchOneObject($select, $prototype);
100
    }
101
 
102
 
103
 
104
 
105
 
106
    /**
107
     *
108
     * @param CompanySelfEvaluationFormUser $form
109
     * @return boolean
110
     */
111
    public function insert($form)
112
    {
113
        $hydrator = new ObjectPropertyHydrator();
114
        $values = $hydrator->extract($form);
115
        $values = $this->removeEmpty($values);
116
 
117
        $insert = $this->sql->insert(self::_TABLE);
118
        $insert->values($values);
119
 
120
        $result = $this->executeInsert($insert);
121
        if($result) {
122
            $form->id = $this->lastInsertId;
123
        }
124
        return $result;
125
    }
126
 
127
    /**
128
     *
129
     * @param CompanySelfEvaluationFormUser $form
130
     * @return boolean
131
     */
132
    public function update($form)
133
    {
134
        $hydrator = new ObjectPropertyHydrator();
135
        $values = $hydrator->extract($form);
136
        $values = $this->removeEmpty($values);
137
 
138
        $update = $this->sql->update(self::_TABLE);
139
        $update->set($values);
140
        $update->where->equalTo('id', $form->id);
141
 
142
        return $this->executeUpdate($update);
143
    }
144
 
145
    /**
146
     *
259 efrain 147
     * @param int $form_id
236 efrain 148
     * @return boolean
149
     */
259 efrain 150
    public function deleteAllByFormId($form_id)
236 efrain 151
    {
152
        $delete = $this->sql->delete(self::_TABLE);
259 efrain 153
        $delete->where->equalTo('id', $form_id);
236 efrain 154
 
155
        return $this->executeDelete($delete);
156
    }
157
 
158
 
159
 
160
 
161
}