Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 3018 Rev 6749
Línea 154... Línea 154...
154
        $select->where->equalTo('receiver_id', $receiver_id)
154
        $select->where->equalTo('receiver_id', $receiver_id)
155
        ->and->equalTo('receiver_status', Message::STATUS_NORMAL);
155
        ->and->equalTo('receiver_status', Message::STATUS_NORMAL);
156
        $select->order('id desc');
156
        $select->order('id desc');
157
        $select->limit(1);
157
        $select->limit(1);
Línea 158... Línea 158...
158
        
158
        
Línea 159... Línea 159...
159
        //error_log($select->getSqlString($this->adapter->platform));
159
       // echo $select->getSqlString($this->adapter->platform) . "\r\n";
-
 
160
        
-
 
161
        $record = $this->executeFetchOneArray($select);
-
 
162
        
-
 
163
        
-
 
164
        
-
 
165
        if($record) {
-
 
166
            return $record['added_on'];
-
 
167
        }  else {
-
 
168
            return '';
-
 
169
        }
-
 
170
        
-
 
171
    }
-
 
172
    
-
 
173
    /**
-
 
174
     *
-
 
175
     * @param int $conversation_id
-
 
176
     * @return string
-
 
177
     */
-
 
178
    public function fetchLastMessageByConversation($conversation_id)
-
 
179
    {
-
 
180
        $select = $this->sql->select(self::_TABLE);
-
 
181
        $select->columns(['added_on' => new Expression('MAX(added_on)')  ]);
-
 
182
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
183
        $select->where->equalTo('receiver_status', Message::STATUS_NORMAL);
-
 
184
        $select->order('id desc');
-
 
185
        $select->limit(1);
-
 
186
        
-
 
187
        // echo $select->getSqlString($this->adapter->platform) . "\r\n";
-
 
188
        
-
 
189
        $record = $this->executeFetchOneArray($select);
-
 
190
        
160
        
191
        
161
        $record = $this->executeFetchOneArray($select);
192
        
-
 
193
        if($record) {
-
 
194
            return $record['added_on'];
162
        if($record) {
195
        }  else {
Línea 163... Línea 196...
163
            return $record['added_on'];
196
            return '';
-
 
197
        }
-
 
198
        
-
 
199
    }
-
 
200
    
-
 
201
    /**
-
 
202
     * 
-
 
203
     * @param int $conversation_id
-
 
204
     * return int
-
 
205
     */
-
 
206
    public function fetchCountMessagesByConversationId($conversation_id)
-
 
207
    {
-
 
208
        $select = $this->sql->select(self::_TABLE);
-
 
209
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
210
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
211
    
-
 
212
        $record = $this->executeFetchOneArray($select);
-
 
213
        return intval($record['total'], 10);
-
 
214
    
-
 
215
    }
-
 
216
    
-
 
217
    /**
-
 
218
     *
-
 
219
     * @param int $conversation_id
-
 
220
     * @param int $message_id
-
 
221
     * return int
-
 
222
     */
-
 
223
    public function fetchCountMessagesByConversationIdAndGreaterThanMessageId($conversation_id, $message_id)
-
 
224
    {
-
 
225
        $select = $this->sql->select(self::_TABLE);
-
 
226
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
227
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
228
        $select->where->greaterThan('id', $message_id);
-
 
229
        
-
 
230
        $record = $this->executeFetchOneArray($select);
-
 
231
        return intval($record['total'], 10);
-
 
232
        
-
 
233
    }
-
 
234
    
-
 
235
    /**
-
 
236
     *
-
 
237
     * @param int $conversation_id
-
 
238
     * @param int $message_id
-
 
239
     * return int
-
 
240
     */
-
 
241
    public function fetchCountMessagesByConversationIdAndLessThanMessageId($conversation_id, $message_id)
-
 
242
    {
-
 
243
        $select = $this->sql->select(self::_TABLE);
-
 
244
        $select->columns(['total' => new Expression('COUNT(*)')]);
-
 
245
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
246
        $select->where->lessThan('id', $message_id);
-
 
247
        
-
 
248
        $record = $this->executeFetchOneArray($select);
-
 
249
        return intval($record['total'], 10);
-
 
250
        
-
 
251
    }
-
 
252
    
-
 
253
    /**
-
 
254
     *
-
 
255
     * @param int $conversation_id
-
 
256
     * @param int $message_id
-
 
257
     * @return Message[]
-
 
258
     */
-
 
259
    public function fetchBatchMessagesByConversationIdAndGreaterThanMessageId($conversation_id, $message_id)
-
 
260
    {
-
 
261
        $select = $this->sql->select(self::_TABLE);
-
 
262
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
263
        $select->where->greaterThan('id', $message_id);
-
 
264
        $select->order('id DESC');
-
 
265
        $select->limit(10);
-
 
266
        
-
 
267
        $prototype  = new Message();
-
 
268
        
-
 
269
        
-
 
270
        return $this->executeFetchAllObject($select, $prototype);
-
 
271
    }
-
 
272
    
-
 
273
    /**
-
 
274
     *
-
 
275
     * @param int $conversation_id
-
 
276
     * @param int $message_id
-
 
277
     * @return Message[]
-
 
278
     */
-
 
279
    public function fetchBatchMessagesByConversationIdAndLessThanMessageId($conversation_id, $message_id)
-
 
280
    {
-
 
281
        $select = $this->sql->select(self::_TABLE);
-
 
282
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
283
        $select->where->lessThan('id', $message_id);
-
 
284
        $select->order('id DESC');
-
 
285
        $select->limit(10);
-
 
286
        
-
 
287
        $prototype  = new Message();
-
 
288
        
-
 
289
        
-
 
290
        return $this->executeFetchAllObject($select, $prototype);
-
 
291
    }
-
 
292
    
-
 
293
    
-
 
294
    /**
-
 
295
     *
-
 
296
     * @param int $conversation_id
-
 
297
     * @param int $message_id
-
 
298
     * @return Message[]
-
 
299
     */
-
 
300
    public function fetchBatchMessagesByConversationId($conversation_id)
-
 
301
    {
-
 
302
        $select = $this->sql->select(self::_TABLE);
-
 
303
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
304
        $select->order('id DESC');
-
 
305
        $select->limit(10);
-
 
306
        
-
 
307
        $prototype  = new Message();
-
 
308
        
-
 
309
        
Línea -... Línea 310...
-
 
310
        return $this->executeFetchAllObject($select, $prototype);
-
 
311
    }
-
 
312
    
-
 
313
 
-
 
314
    
-
 
315
    /**
-
 
316
     *
-
 
317
     * @param int $conversation_id
-
 
318
     * @param int $message_id
-
 
319
     * @param int $page
-
 
320
     * @param int $records_per_page
-
 
321
     * @return Paginator
-
 
322
     */
-
 
323
    public function getAllMessagesPaginatorByConversationIdAndGreaterThanMessageId($conversation_id, $message_id, $page = 1, $records_per_page = 10)
-
 
324
    {
-
 
325
        $select = $this->sql->select(self::_TABLE);
-
 
326
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
327
        $select->where->greaterThan('id', $message_id);
-
 
328
        $select->order('id DESC');
-
 
329
        
-
 
330
        //echo $select->getSqlString($this->adapter->getPlatform()); exit;
-
 
331
        
-
 
332
        $prototype  = new Message();
-
 
333
        $hydrator   = new ObjectPropertyHydrator();
-
 
334
        $resultset  = new HydratingResultSet($hydrator, $prototype);
-
 
335
        
-
 
336
        $adapter    = new DbSelect($select, $this->sql, $resultset);
-
 
337
        $paginator  = new Paginator($adapter);
-
 
338
        $paginator->setCurrentPageNumber($page);
-
 
339
        $paginator->setItemCountPerPage($records_per_page);
-
 
340
        
-
 
341
        return $paginator;
-
 
342
    }
-
 
343
    
-
 
344
    
-
 
345
    
-
 
346
    /**
-
 
347
     *
-
 
348
     * @param int $conversation_id
-
 
349
     * @param int $message_id
-
 
350
     * @param int $page
-
 
351
     * @param int $records_per_page
-
 
352
     * @return Paginator
-
 
353
     */
-
 
354
    public function getAllMessagesPaginatorByConversationIdAndLessThanMessageId($conversation_id, $message_id, $page = 1, $records_per_page = 10)
-
 
355
    {
-
 
356
        $select = $this->sql->select(self::_TABLE);
-
 
357
        $select->where->equalTo('conversation_id', $conversation_id);
-
 
358
        $select->where->lessThan('id', $message_id);
-
 
359
        $select->order('id DESC');
-
 
360
        
-
 
361
        //echo $select->getSqlString($this->adapter->getPlatform()); exit;
-
 
362
        
-
 
363
        $prototype  = new Message();
-
 
364
        $hydrator   = new ObjectPropertyHydrator();
-
 
365
        $resultset  = new HydratingResultSet($hydrator, $prototype);
-
 
366
        
-
 
367
        $adapter    = new DbSelect($select, $this->sql, $resultset);
-
 
368
        $paginator  = new Paginator($adapter);
-
 
369
        $paginator->setCurrentPageNumber($page);
Línea 164... Línea 370...
164
        } 
370
        $paginator->setItemCountPerPage($records_per_page);
165
        
371
        
166
    }
372
        return $paginator;
167
 
373
    }
168
 
374
 
169
    
375
    
170
    /**
376
    /**
171
     *
377
     *
172
     * @param int $chat_id
378
     * @param int $conversation_id
173
     * @param int $page
379
     * @param int $page
174
     * @param int $records_per_page
380
     * @param int $records_per_page
175
     * @return Paginator
381
     * @return Paginator
Línea 176... Línea -...
176
     */
-
 
177
    public function getAllMessagesPaginatorByConversationId($conversation_id, $page = 1, $records_per_page = 10)
-
 
178
    {
382
     */
179
        $select = $this->sql->select(self::_TABLE);
383
    public function getAllMessagesPaginatorByConversationId($conversation_id, $page = 1, $records_per_page = 10)
180
        $select->where->equalTo('conversation_id', $conversation_id);
384
    {
Línea 181... Línea 385...
181
        $select->order('id DESC');
385
        $select = $this->sql->select(self::_TABLE);