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 LeadersLinked\Model\UserSkill;
8
use LeadersLinked\Mapper\Common\MapperCommon;
9
use Laminas\Db\Adapter\AdapterInterface;
10
use Laminas\Log\LoggerInterface;
11
use LeadersLinked\Model\Skill;
12
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
13
 
14
 
15
class UserSkillMapper extends MapperCommon
16
{
17
    const _TABLE = 'tbl_user_skills';
18
 
19
 
20
    /**
21
     *
22
     * @var UserSkillMapper
23
     */
24
    private static $_instance;
25
 
26
    /**
27
     *
28
     * @param AdapterInterface $adapter
29
     */
30
    private function __construct($adapter)
31
    {
32
        parent::__construct($adapter);
33
    }
34
 
35
    /**
36
     *
37
     * @param AdapterInterface $adapter
38
     * @return \LeadersLinked\Mapper\UserSkillMapper
39
     */
40
    public static function getInstance($adapter)
41
    {
42
        if(self::$_instance == null) {
43
            self::$_instance = new UserSkillMapper($adapter);
44
        }
45
        return self::$_instance;
46
    }
47
 
48
    /**
49
     *
50
     * @param int $user_id
51
     * @return UserSkill[]
52
     */
53
    public function fetchAllByUserId($user_id)
54
    {
55
        $prototype = new UserSkill;
56
        $select = $this->sql->select(self::_TABLE);
57
        $select->where->equalTo('user_id', $user_id);
58
 
59
        return $this->executeFetchAllObject($select, $prototype);
60
    }
61
 
62
    /**
63
     *
64
     * @param int $user_profile_id
65
     * @return UserSkill[]
66
     */
67
    public function fetchAllByUserProfileId($user_profile_id)
68
    {
69
        $prototype = new UserSkill;
70
        $select = $this->sql->select(self::_TABLE);
71
        $select->where->equalTo('user_profile_id', $user_profile_id);
72
 
73
        return $this->executeFetchAllObject($select, $prototype);
74
    }
75
 
76
 
77
 
78
 
79
    /**
80
     *
81
     * @param int $user_profile_id
82
     * @return boolean
83
     */
84
    public function deleteByUserProfileId($user_profile_id)
85
    {
86
        $delete = $this->sql->delete(self::_TABLE);
87
        $delete->where->equalTo('user_profile_id', $user_profile_id);
88
 
89
        return $this->executeDelete($delete);
90
    }
91
 
92
 
93
    /**
94
     *
95
     * @param UserSkill $userSkill
96
     * @return boolean
97
     */
98
    public function insert($userSkill)
99
    {
100
        $hydrator = new ObjectPropertyHydrator();
101
        $values = $hydrator->extract($userSkill);
102
        $values = $this->removeEmpty($values);
103
 
104
        $insert = $this->sql->insert(self::_TABLE);
105
        $insert->values($values);
106
 
107
        return $this->executeInsert($insert);
108
 
109
    }
110
 
111
}