Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

| 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 Laminas\Db\Adapter\AdapterInterface;
8
use Laminas\Log\LoggerInterface;
9
 
10
use LeadersLinked\Mapper\Common\MapperCommon;
11
use LeadersLinked\Model\Route;
12
 
13
class RouteMapper extends MapperCommon
14
{
15
    const _TABLE = 'tbl_routes';
16
 
17
    /**
18
     *
19
     * @var RouteMapper
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 RouteMapper
36
     */
37
    public static function getInstance($adapter)
38
    {
39
        if(self::$_instance == null) {
40
            self::$_instance = new  RouteMapper($adapter);
41
        }
42
        return self::$_instance;
43
    }
44
 
45
    /**
46
     *
47
     * @return Route[]
48
     */
49
    public function fetchAllPublic()
50
    {
51
        $prototype = new Route();
52
        $select = $this->sql->select(self::_TABLE);
53
        $select->where->equalTo('public', Route::YES);
54
 
55
        return $this->executeFetchAllObject($select, $prototype);
56
    }
57
 
58
    /**
59
     *
60
     * @return Route[]
61
     */
62
    public function fetchAllRequired()
63
    {
64
        $prototype = new Route();
65
        $select = $this->sql->select(self::_TABLE);
66
        $select->where->equalTo('required', Route::YES);
67
 
68
        return $this->executeFetchAllObject($select, $prototype);
69
    }
70
 
71
 
72
    /**
73
     *
74
     * @return Route[]
75
     */
76
    public function fetchAll()
77
    {
78
        $prototype = new Route();
79
        $select = $this->sql->select(self::_TABLE);
80
 
81
 
82
        return $this->executeFetchAllObject($select, $prototype);
83
    }
84
 
85
 
86
 
87
    /**
88
     *
89
     * @return boolean
90
     */
91
    public function truncate()
92
    {
93
        $sql = sprintf('TRUNCATE TABLE `%s` ', self::_TABLE);
94
        return $this->executeSentenceWithParameters($sql);
95
    }
96
 
97
}