AccessRightRepository::deleteAllUsersList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Repository;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\ORM\EntityRepository;
7
use PiouPiou\RibsAdminBundle\Entity\AccessRight;
8
9
class AccessRightRepository extends EntityRepository
10
{
11
    /**
12
     * function that delete all user which are in a list of rights
13
     * @param AccessRight $access_right
14
     * @throws DBALException
15
     */
16
    public function deleteAllUsersList(AccessRight $access_right)
17
    {
18
        $query = $this->getEntityManager()->getConnection()->prepare("UPDATE user SET id_access_right = NULL WHERE
19
 			id_access_right = :id_access_right
20
 		");
21
        $query->bindValue("id_access_right", $access_right->getId());
22
        $query->execute();
23
    }
24
25
    /**
26
     * function that add a user in an access right list
27
     * @param int $access_right_id
28
     * @param string $guid_admin
29
     * @throws DBALException
30
     */
31
    public function setAccessRightListUser(int $access_right_id, string $guid_admin)
32
    {
33
        $query = $this->getEntityManager()->getConnection()->prepare("UPDATE user SET id_access_right = :id_access_right WHERE
34
 			guid = :guid_user
35
 		");
36
        $query->bindValue("id_access_right", $access_right_id, \PDO::PARAM_INT);
37
        $query->bindValue("guid_user", $guid_admin, \PDO::PARAM_STR);
38
        $query->execute();
39
    }
40
}
41