Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6388 | Ir a la última revisión | | 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\MyCoachQuestion;
10
 
11
 
12
class MyCoachQuestionMapper extends MapperCommon
13
{
14
    const _TABLE = 'tbl_my_coach_questions';
15
 
16
    /**
17
     *
18
     * @var MyCoachQuestionMapper
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 MyCoachQuestionMapper
35
     */
36
    public static function getInstance($adapter)
37
    {
38
        if(self::$_instance == null) {
39
            self::$_instance = new MyCoachQuestionMapper($adapter);
40
        }
41
        return self::$_instance;
42
    }
43
 
44
    /**
45
     *
46
     * @param int $category_id
47
     * @param int $user_id
48
     * @return MyCoachQuestion
49
     */
50
    public function fetchOneByCategoryIdAndUserId($category_id, $user_id)
51
    {
52
 
53
        $select = $this->sql->select(self::_TABLE);
54
        $select->where->equalTo('category_id', $category_id);
55
        $select->where->equalTo('user_id', $user_id);
56
 
57
        $prototype = new MyCoachQuestion();
58
        return $this->executeFetchOneObject($select, $prototype);
59
    }
60
 
61
 
62
 
63
 
64
 
65
 
66
    /**
67
     *
68
     * @param
69
     * @return MyCoachQuestion[]
70
     */
71
    public function fetchAllByCategoryId($category_id)
72
    {
73
 
74
        $select = $this->sql->select(self::_TABLE);
75
        $select->where->equalTo('category_id', $category_id);
76
 
77
 
78
        $prototype = new MyCoachQuestion();
79
        return $this->executeFetchAllObject($select, $prototype);
80
    }
81
 
82
    /**
83
     *
84
     * @param int $category_id
85
     * @param int $user_id
86
     * @return boolean
87
     */
88
    public function deleteByCategoryIdAndUserId($category_id, $user_id)
89
    {
90
        $delete = $this->sql->delete(self::_TABLE);
91
        $delete->where->equalTo('category_id', $category_id);
92
        $delete->where->equalTo('user_id', $user_id);
93
 
94
        return $this->executeDelete($delete);
95
    }
96
 
97
}