Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Ir a la última revisión | | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 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\Application;
10
 
11
 
12
class ApplicationMapper extends MapperCommon
13
{
14
    const _TABLE = 'tbl_applications';
15
 
16
    /**
17
     *
18
     * @var ApplicationMapper
19
     */
20
    private static $_instance;
21
 
22
    /**
23
     *
24
     * @param AdapterInterface $adapter
25
     */
26
    private function __construct($adapter)
27
    {
28
        parent::__construct($adapter);
29
    }
30
 
31
    /**
32
     *
33
     * @param AdapterInterface $adapter
34
     * @return ApplicationMapper
35
     */
36
    public static function getInstance($adapter)
37
    {
38
        if(self::$_instance == null) {
39
            self::$_instance = new ApplicationMapper($adapter);
40
        }
41
        return self::$_instance;
42
    }
43
 
44
    /**
45
     *
46
     * @param int $id
47
     * @return Application
48
     */
49
    public function fetchOne($id)
50
    {
51
 
52
        $select = $this->sql->select(self::_TABLE);
53
        $select->where->equalTo('id', $id);
54
 
55
        $prototype = new Application();
56
        return $this->executeFetchOneObject($select, $prototype);
57
    }
58
 
59
 
60
    /**
61
     *
62
     * @return Application[]
63
     */
64
    public function fetchAll()
65
    {
66
 
67
        $select = $this->sql->select(self::_TABLE);
68
 
69
        $prototype = new Application();
70
        return $this->executeFetchAllObject($select, $prototype);
71
    }
72
 
73
}