Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6481 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6481 Rev 6521
Línea 5... Línea 5...
5
 
5
 
6
 
6
 
7
use LeadersLinked\Mapper\Common\MapperCommon;
7
use LeadersLinked\Mapper\Common\MapperCommon;
-
 
8
use Laminas\Db\Adapter\AdapterInterface;
-
 
9
use LeadersLinked\Model\MyCoachAnswer;
Línea 8... Línea 10...
8
use Laminas\Db\Adapter\AdapterInterface;
10
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
9
use LeadersLinked\Model\MyCoachAnswer;
11
use Laminas\Db\Sql\Expression;
10
 
12
 
Línea 44... Línea 46...
44
    /**
46
    /**
45
     * 
47
     * 
46
     * @param int $id
48
     * @param int $id
47
     * @return MyCoachAnswer
49
     * @return MyCoachAnswer
48
     */
50
     */
49
    public function fetchOneByAnswer($id)
51
    public function fetchOne($id)
50
    {
52
    {
Línea 51... Línea 53...
51
        
53
        
52
        $select = $this->sql->select(self::_TABLE);
54
        $select = $this->sql->select(self::_TABLE);
Línea 56... Línea 58...
56
        return $this->executeFetchOneObject($select, $prototype);
58
        return $this->executeFetchOneObject($select, $prototype);
57
    }
59
    }
Línea -... Línea 60...
-
 
60
    
-
 
61
    
-
 
62
    
-
 
63
    /**
-
 
64
     *
-
 
65
     * @param string $uuid
-
 
66
     * @return MyCoachAnswer
-
 
67
     */
-
 
68
    public function fetchOneByUuid($uuid)
-
 
69
    {
-
 
70
        
-
 
71
        $select = $this->sql->select(self::_TABLE);
-
 
72
        $select->where->equalTo('uuid', $uuid);
-
 
73
        
-
 
74
        $prototype = new MyCoachAnswer();
-
 
75
        return $this->executeFetchOneObject($select, $prototype);
-
 
76
    }
-
 
77
    
Línea 58... Línea 78...
58
    
78
    
59
    
79
    
Línea 92... Línea 112...
92
        
112
        
93
        $prototype = new MyCoachAnswer();
113
        $prototype = new MyCoachAnswer();
94
        return $this->executeFetchOneObject($select, $prototype);
114
        return $this->executeFetchOneObject($select, $prototype);
Línea -... Línea 115...
-
 
115
    }
-
 
116
    
-
 
117
    
-
 
118
    /**
-
 
119
     *
-
 
120
     * @param int $my_coach_question_id
-
 
121
     * @return int
-
 
122
     */
-
 
123
    public function fetchCountByMyCoachQuestionId($my_coach_question_id)
-
 
124
    {
-
 
125
        $select = $this->sql->select(self::_TABLE);
-
 
126
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
127
        $select->where->equalTo('question_id', $my_coach_question_id);
-
 
128
 
-
 
129
        $record = $this->executeFetchOneArray($select);
-
 
130
        return $record['total'];
-
 
131
    }
-
 
132
    
-
 
133
    
-
 
134
    /**
-
 
135
     *
-
 
136
     * @param int $question_id
-
 
137
     * @return boolean
-
 
138
     */
-
 
139
    public function deleteAllByQuestionId($question_id )
-
 
140
    {
-
 
141
        $delete = $this->sql->delete(self::_TABLE);
-
 
142
        $delete->where->equalTo('question_id', $question_id);
-
 
143
        
-
 
144
        return $this->executeDelete($delete);
-
 
145
    }
-
 
146
    
-
 
147
    
-
 
148
    /**
-
 
149
     *
-
 
150
     * @param  MyCoachAnswer $record
-
 
151
     * @return boolean
-
 
152
     */
-
 
153
    public function delete($record)
-
 
154
    {
-
 
155
        $delete = $this->sql->delete(self::_TABLE);
-
 
156
        $delete->where->equalTo('id', $record->id);
-
 
157
        
-
 
158
        return $this->executeDelete($delete);
-
 
159
    }
-
 
160
    
-
 
161
    
-
 
162
    /**
-
 
163
     *
-
 
164
     * @param MyCoachAnswer $record
-
 
165
     * @return boolean
-
 
166
     */
-
 
167
    public function insert($record)
-
 
168
    {
-
 
169
        $hydrator = new ObjectPropertyHydrator();
-
 
170
        $values = $hydrator->extract($record);
-
 
171
        $values = $this->removeEmpty($values);
-
 
172
        
-
 
173
        $insert = $this->sql->insert(self::_TABLE);
-
 
174
        $insert->values($values);
-
 
175
        
-
 
176
        
-
 
177
        $result = $this->executeInsert($insert);
-
 
178
        if ($result) {
-
 
179
            $record->id = $this->lastInsertId;
-
 
180
        }
-
 
181
        
-
 
182
        return $result;
-
 
183
    }
-
 
184
    
-
 
185
    /**
-
 
186
     *
-
 
187
     * @param MyCoachAnswer $record
-
 
188
     * @return boolean
-
 
189
     */
-
 
190
    public function update($record)
-
 
191
    {
-
 
192
        $hydrator = new ObjectPropertyHydrator();
-
 
193
        $values = $hydrator->extract($record);
-
 
194
        $values = $this->removeEmpty($values);
-
 
195
        
-
 
196
        $update = $this->sql->update(self::_TABLE);
-
 
197
        $update->set($values);
-
 
198
        $update->where->equalTo('id', $record->id);
-
 
199
        
-
 
200
        return $this->executeUpdate($update);
Línea 95... Línea 201...
95
    }
201
    }
96
    
202