Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
41 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Mapper;
6
 
7
use Laminas\Db\Adapter\AdapterInterface;
8
use LeadersLinked\Model\SyncLog;
9
use LeadersLinked\Mapper\Common\MapperCommon;
10
 
11
 
12
class SyncLogMapper extends MapperCommon
13
{
14
    const _TABLE = 'tbl_sync_logs';
15
 
16
 
17
    /**
18
     *
19
     * @var SyncLogMapper
20
     */
21
    private static $_instance;
22
 
23
    /**
24
     *
25
     * @param AdapterInterface $adapter
26
     */
27
    private function __construct($adapter)
28
    {
29
        parent::__construct($adapter);
30
    }
31
 
32
    /**
33
     *
34
     * @param AdapterInterface $adapter
35
     * @return SyncLogMapper
36
     */
37
    public static function getInstance($adapter)
38
    {
39
        if(self::$_instance == null) {
40
            self::$_instance = new SyncLogMapper($adapter);
41
        }
42
        return self::$_instance;
43
    }
44
 
45
    /**
46
     *
47
     * @param int $id
48
     * @return SyncLog
49
     */
50
    public function fetchOne($id)
51
    {
52
        $prototype = new SyncLog();
53
 
54
        $select = $this->sql->select(self::_TABLE);
55
        $select->where->equalTo('id', $id);
56
 
57
        return $this->executeFetchOneObject($select, $prototype);
58
    }
59
 
60
 
61
    /**
62
     *
63
     * @param int $device_uuid
64
     * @return SyncLog[]
65
     */
66
    public function fetchAllByDeviceUuid($device_uuid)
67
    {
68
        $prototype = new SyncLog();
69
 
70
        $select = $this->sql->select(self::_TABLE);
71
        $select->where->equalTo('device_uuid', $device_uuid);
72
 
73
        return $this->executeFetchAllObject($select, $prototype);
74
    }
75
 
76
    /**
77
     *
78
     * @param SyncLog $syncLog
79
     * return true
80
     */
81
    public function insert($syncLog)
82
    {
83
        $hydrator = new \Laminas\Hydrator\ObjectPropertyHydrator();
84
        $values = $hydrator->extract($syncLog);
85
        $values = $this->removeEmpty($values);
86
 
87
 
88
        $insert = $this->sql->insert(self::_TABLE);
89
        $insert->values($values);
90
 
91
        $result = $this->executeInsert($insert);
92
        if($result) {
93
            $syncLog->id = $this->lastInsertId;
94
        }
95
 
96
        return $result;
97
    }
98
 
99
 
100
 
101
 
102
}