Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
4689 efrain 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Mapper;
5
 
6
 
7
use LeadersLinked\Mapper\Common\MapperCommon;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use LeadersLinked\Model\ZoomMeeting;
10
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
11
 
12
 
13
class ZoomMeetingMapper extends MapperCommon
14
{
15
    const _TABLE = 'tbl_zoom_meetings';
16
 
17
    /**
18
     *
19
     * @var ZoomMeetingMapper
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 ZoomMeetingMapper
36
     */
37
    public static function getInstance($adapter)
38
    {
39
        if(self::$_instance == null) {
40
            self::$_instance = new ZoomMeetingMapper($adapter);
41
        }
42
        return self::$_instance;
43
    }
44
 
45
    /**
46
     *
47
     * @param int $id
48
     * @return ZoomMeeting
49
     */
50
    public function fetchOne($id)
51
    {
52
 
53
        $select = $this->sql->select(self::_TABLE);
54
        $select->where->equalTo('id', $id);
55
 
56
        $prototype = new ZoomMeeting();
57
        return $this->executeFetchOneObject($select, $prototype);
58
    }
59
 
60
    /**
61
     *
62
     * @param string $uuid
63
     * @return ZoomMeeting
64
     */
65
    public function fetchOneByUuid($uuid)
66
    {
67
 
68
        $select = $this->sql->select(self::_TABLE);
69
        $select->where->equalTo('uuid', $uuid);
70
 
71
        $prototype = new ZoomMeeting();
72
        return $this->executeFetchOneObject($select, $prototype);
73
    }
74
 
75
    /**
76
     *
77
     * @param ZoomMeeting $zoomMeeting
78
     * @return boolean
79
     */
80
    public function insert($zoomMeeting)
81
    {
82
        $hydrator = new ObjectPropertyHydrator();
83
        $values = $hydrator->extract($zoomMeeting);
84
        $values = $this->removeEmpty($values);
85
 
86
        $insert = $this->sql->insert(self::_TABLE);
87
        $insert->values($values);
88
 
89
        return $this->executeInsert($insert);
90
    }
91
 
92
    /**
93
     *
94
     * @param ZoomMeeting $zoomMeeting
95
     * @return boolean
96
     */
97
    public function update($zoomMeeting)
98
    {
99
        $hydrator = new ObjectPropertyHydrator();
100
        $values = $hydrator->extract($zoomMeeting);
101
        $values = $this->removeEmpty($values);
102
 
103
        $update = $this->sql->update(self::_TABLE);
104
        $update->set($values);
105
        $update->where->equalTo('id', $zoomMeeting->id);
106
 
107
        return $this->executeUpdate($update);
108
    }
109
 
110
    /**
111
     *
112
     * @param ZoomMeeting $zoomMeeting
113
     * @return boolean
114
     */
115
    public function delete($zoomMeeting)
116
    {
117
        $delete = $this->sql->delete(self::_TABLE);
118
        $delete->where->equalTo('id', $zoomMeeting->id);
119
 
120
        return $this->executeDelete($delete);
121
 
122
 
123
    }
124
 
125
 
126
}