Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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