Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 2068 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace LeadersLinked\Mapper;
6
 
7
use LeadersLinked\Model\ChatGroup;
8
use LeadersLinked\Mapper\Common\MapperCommon;
9
use Laminas\Db\Adapter\AdapterInterface;
10
use Laminas\Log\LoggerInterface;
11
use Laminas\Db\Sql\Expression;
12
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
13
 
14
class ChatGroupMapper extends MapperCommon
15
{
16
    const _TABLE = 'tbl_chat_groups';
17
 
18
    /**
19
     *
20
     * @var ChatGroupMapper
21
     */
22
    private static $_instance;
23
 
24
    /**
25
     *
26
     * @param AdapterInterface $adapter
27
     */
28
    private function __construct($adapter)
29
    {
30
        parent::__construct($adapter);
31
    }
32
 
33
    /**
34
     *
35
     * @param AdapterInterface $adapter
36
     * @return ChatGroupMapper
37
     */
38
    public static function getInstance($adapter)
39
    {
40
        if(self::$_instance == null) {
41
            self::$_instance = new ChatGroupMapper($adapter);
42
        }
43
        return self::$_instance;
44
    }
45
 
46
    /**
47
     *
48
     * @param ChatGroup $chatGroup
49
     * @return boolean
50
     */
51
    public function insert($chatGroup)
52
    {
53
        $hydrator = new ObjectPropertyHydrator();
54
        $values = $hydrator->extract($chatGroup);
55
        $values = $this->removeEmpty($values);
56
 
57
        $insert = $this->sql->insert(self::_TABLE);
58
        $insert->values($values);
59
 
60
        //echo $insert->getSqlString($this->adapter->getPlatform());
61
 
62
        $result = $this->executeInsert($insert);
63
        if($result) {
64
            $chatGroup->id = $this->lastInsertId;
65
        }
66
        return $result;
67
     }
68
 
69
 
70
    /**
71
     *
72
     * @param string $id
73
     * @return boolean
74
     */
75
    public function deleteByGroupId($id)
76
    {
77
        $delete = $this->sql->delete(self::_TABLE);
78
        $delete->where->equalTo('id', $id);
79
 
80
        return $this->executeDelete($delete);
81
    }
82
 
83
 
84
    /**
85
     *
86
     * @param string $id
87
     * @return  ChatGroup
88
     */
89
    public function fetchOne($id)
90
    {
91
        $prototype = new ChatGroup();
92
        $select = $this->sql->select(self::_TABLE);
93
        $select->where->equalTo('id', $id);
94
        $select->limit(1);
95
        return $this->executeFetchOneObject($select, $prototype);
96
    }
97
 
2062 nelberth 98
    public function fetchOneHptg($id)
99
    {
100
        $prototype = new ChatGroup();
101
        $select = $this->sql->select(self::_TABLE);
2158 nelberth 102
        $select->where->equalTo('high_performance_team_group_id', $id);
2062 nelberth 103
        $select->limit(1);
104
        return $this->executeFetchOneObject($select, $prototype);
105
    }
106
 
1 www 107
 
108
    /**
109
     *
110
     * @param string $uuid
111
     * @return  ChatGroup
112
     */
113
    public function fetchOneByUuid($uuid)
114
    {
115
        $prototype = new ChatGroup();
116
        $select = $this->sql->select(self::_TABLE);
117
        $select->where->equalTo('uuid', $uuid);
118
        $select->limit(1);
119
        return $this->executeFetchOneObject($select, $prototype);
120
    }
121
 
2064 nelberth 122
    public function update($form)
123
    {
124
        $hydrator = new ObjectPropertyHydrator();
125
        $values = $hydrator->extract($form);
126
        $values = $this->removeEmpty($values);
127
 
128
        $update = $this->sql->update(self::_TABLE);
129
        $update->set($values);
2158 nelberth 130
        $update->where->equalTo('high_performance_team_group_id', $form->high_performance_team_group_id );
2064 nelberth 131
        return $this->executeUpdate($update);
132
    }
133
 
1 www 134
 
2064 nelberth 135
 
1 www 136
}