Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 4235 | Rev 5834 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 4235 Rev 5833
Línea 1... Línea 1...
1
<?php
1
<?php
-
 
2
 
2
declare(strict_types=1);
3
declare(strict_types=1);
Línea 3... Línea 4...
3
 
4
 
Línea 20... Línea 21...
20
    /**
21
    /**
21
     *
22
     *
22
     * @var DiscoveryContactLogMapper
23
     * @var DiscoveryContactLogMapper
23
     */
24
     */
24
    private static $_instance;
25
    private static $_instance;
25
    
26
 
26
    /**
27
    /**
27
     *
28
     *
28
     * @param AdapterInterface $adapter
29
     * @param AdapterInterface $adapter
29
     */
30
     */
30
    private function __construct($adapter)
31
    private function __construct($adapter)
31
    {
32
    {
32
        parent::__construct($adapter);
33
        parent::__construct($adapter);
33
    }
34
    }
34
    
35
 
35
    /**
36
    /**
36
     *
37
     *
37
     * @param AdapterInterface $adapter
38
     * @param AdapterInterface $adapter
38
     * @return DiscoveryContactLogMapper
39
     * @return DiscoveryContactLogMapper
39
     */
40
     */
40
    public static function getInstance($adapter)
41
    public static function getInstance($adapter)
41
    {
42
    {
42
        if(self::$_instance == null) {
43
        if (self::$_instance == null) {
43
            self::$_instance = new DiscoveryContactLogMapper($adapter);
44
            self::$_instance = new DiscoveryContactLogMapper($adapter);
44
        }
45
        }
45
        return self::$_instance;
46
        return self::$_instance;
46
    }
47
    }
47
    
48
 
-
 
49
    /**
-
 
50
     * 
-
 
51
     * @param int $id
-
 
52
     * @return DiscoveryContact
-
 
53
     */
-
 
54
    public function fetchAll()
-
 
55
    {
-
 
56
 
-
 
57
        $select = $this->sql->select(self::_TABLE);
-
 
58
        //$select->where->equalTo('id', $id);
-
 
59
 
-
 
60
        $prototype = new DiscoveryContact();
-
 
61
        return $this->executeFetchOneObject($select, $prototype);
-
 
62
    }
-
 
63
 
48
    /**
64
    /**
49
     * 
65
     * 
50
     * @param int $id
66
     * @param int $id
51
     * @return DiscoveryContactLogMapper
67
     * @return DiscoveryContactLogMapper
52
     */
68
     */
53
    public function fetchOne($id)
69
    public function fetchOne($id)
54
    {
70
    {
55
        
71
 
56
        $select = $this->sql->select(self::_TABLE);
72
        $select = $this->sql->select(self::_TABLE);
57
        $select->where->equalTo('id', $id);
73
        $select->where->equalTo('id', $id);
58
        
74
 
59
        $prototype = new DiscoveryContactLog();
75
        $prototype = new DiscoveryContactLog();
60
        return $this->executeFetchOneObject($select, $prototype);
76
        return $this->executeFetchOneObject($select, $prototype);
61
    }
77
    }
62
    
78
 
63
    /**
79
    /**
64
     *
80
     *
65
     * @param string $uuid
81
     * @param string $uuid
66
     * @return DiscoveryContactLogMapper
82
     * @return DiscoveryContactLogMapper
67
     */
83
     */
68
    public function fetchOneByUuid($uuid)
84
    public function fetchOneByUuid($uuid)
69
    {
85
    {
70
        
86
 
71
        $select = $this->sql->select(self::_TABLE);
87
        $select = $this->sql->select(self::_TABLE);
72
        $select->where->equalTo('uuid', $uuid);
88
        $select->where->equalTo('uuid', $uuid);
73
        
89
 
74
        $prototype = new DiscoveryContactLog();
90
        $prototype = new DiscoveryContactLog();
75
        return $this->executeFetchOneObject($select, $prototype);
91
        return $this->executeFetchOneObject($select, $prototype);
76
    }
92
    }
77
    
93
 
78
    /**
94
    /**
79
     *
95
     *
80
     * @param int $company_id
96
     * @param int $company_id
81
     * @param int $contact_id
97
     * @param int $contact_id
82
     * @param int $page
98
     * @param int $page
Línea 88... Línea 104...
88
        $prototype = new DiscoveryContactLog();
104
        $prototype = new DiscoveryContactLog();
89
        $select = $this->sql->select(self::_TABLE);
105
        $select = $this->sql->select(self::_TABLE);
90
        $select->where->equalTo('company_id', $company_id);
106
        $select->where->equalTo('company_id', $company_id);
91
        $select->where->equalTo('contact_id', $contact_id);
107
        $select->where->equalTo('contact_id', $contact_id);
92
        $select->order('added_on DESC');
108
        $select->order('added_on DESC');
93
        
109
 
94
        $hydrator   = new ObjectPropertyHydrator();
110
        $hydrator   = new ObjectPropertyHydrator();
95
        $resultset  = new HydratingResultSet($hydrator, $prototype);
111
        $resultset  = new HydratingResultSet($hydrator, $prototype);
96
        
112
 
97
        $adapter = new DbSelect($select, $this->sql, $resultset);
113
        $adapter = new DbSelect($select, $this->sql, $resultset);
98
        $paginator = new Paginator( $adapter);
114
        $paginator = new Paginator($adapter);
99
        $paginator->setItemCountPerPage($records_per_page);
115
        $paginator->setItemCountPerPage($records_per_page);
100
        $paginator->setCurrentPageNumber($page);
116
        $paginator->setCurrentPageNumber($page);
101
        
117
 
102
        
118
 
103
        return $paginator;
119
        return $paginator;
104
    }
120
    }
105
    
121
 
106
    
122
 
107
    /**
123
    /**
108
     *
124
     *
109
     * @param DiscoveryContactLog $record
125
     * @param DiscoveryContactLog $record
110
     * @return boolean
126
     * @return boolean
111
     */
127
     */
112
    public function insert($record)
128
    public function insert($record)
113
    {
129
    {
114
        $hydrator = new ObjectPropertyHydrator();
130
        $hydrator = new ObjectPropertyHydrator();
115
        $values = $hydrator->extract($record);
131
        $values = $hydrator->extract($record);
116
        $values = $this->removeEmpty($values);
132
        $values = $this->removeEmpty($values);
117
        
133
 
118
        $insert = $this->sql->insert(self::_TABLE);
134
        $insert = $this->sql->insert(self::_TABLE);
119
        $insert->values($values);
135
        $insert->values($values);
120
        $result = $this->executeInsert($insert);
136
        $result = $this->executeInsert($insert);
121
        
137
 
122
        if($result) {
138
        if ($result) {
123
            $record->id = $this->lastInsertId;
139
            $record->id = $this->lastInsertId;
124
        }
140
        }
125
        
141
 
126
        return $result;
142
        return $result;
127
    }
143
    }
128
    
-
 
129
    
-
 
Línea -... Línea 144...
-
 
144
 
130
 
145
 
-
 
146
 
131
    
147
 
132
    
148
 
133
    
149
 
134
    /**
150
    /**
135
     *
151
     *
136
     * @param DiscoveryContactLog $record
152
     * @param DiscoveryContactLog $record
137
     * @return boolean
153
     * @return boolean
138
     */
154
     */
139
    public function delete($record)
155
    public function delete($record)
140
    {
156
    {
141
        $delete = $this->sql->delete(self::_TABLE);
157
        $delete = $this->sql->delete(self::_TABLE);
142
        $delete->where->equalTo('id', $record->id);
158
        $delete->where->equalTo('id', $record->id);
143
        
159
 
144
        return $this->executeDelete($delete);
-
 
145
        
160
        return $this->executeDelete($delete);
146
    }
-
 
147
 
-
 
148
    
-
 
149
}
161
    }
-
 
162
}