GameReleaseAkaDAO::getAllGameReleaseAkas()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 2
nop 1
dl 0
loc 28
rs 9.6333
c 0
b 0
f 0
1
<?php
2
namespace AL\Common\DAO;
3
4
require_once __DIR__."/../../lib/Db.php" ;
5
require_once __DIR__."/../Model/Game/GameReleaseAka.php" ;
6
require_once __DIR__."/../Model/Language/Language.php" ;
7
8
/**
9
 * DAO for Game Releases AKAs
10
 */
11
12
class GameReleaseAkaDAO {
13
    private $mysqli;
14
15
    public function __construct($mysqli) {
16
        $this->mysqli = $mysqli;
17
    }
18
19
20
    /* Get all Game Release AKA's
21
     *
22
     * @return \AL\Common\Model\Game\GameReleaseAka[] An array of AKAs
23
     */
24
    public function getAllGameReleaseAkas($game_release_id) {
25
        $stmt = \AL\Db\execute_query(
26
            "GameReleaseAkaDAO: getAllGameReleaseAkas",
27
            $this->mysqli,
28
            "SELECT game_release_aka.id, game_release_aka.game_release_id, game_release_aka.name,
29
            game_release_aka.language_id, language.name FROM game_release_aka
30
            LEFT JOIN language ON ( game_release_aka.language_id = language.id )
31
			 WHERE game_release_id = ?",
32
            "i", $game_release_id
33
        );
34
35
        \AL\Db\bind_result(
36
            "GameReleaseAkaDAO: getAllGameReleaseAkas",
37
            $stmt,
38
            $release_aka_id, $release_id, $name, $language_id, $language_name
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $language_name seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $language_id seems to be never defined.
Loading history...
Comprehensibility Best Practice introduced by
The variable $release_id does not exist. Did you maybe mean $game_release_id?
Loading history...
Comprehensibility Best Practice introduced by
The variable $name seems to be never defined.
Loading history...
39
        );
40
41
        $game_release_aka = [];
42
        while ($stmt->fetch()) {
43
            $game_release_aka[] = new \AL\Common\Model\Game\GameReleaseAka(
44
                $release_aka_id, $release_id, $name,
45
                new \AL\Common\Model\Language\Language($language_id, $language_name)
46
            );
47
        }
48
49
        $stmt->close();
50
51
        return $game_release_aka;
52
    }
53
54
    /**
55
     * update language_id for release AKA
56
     *
57
     * @param char language id
58
     * @param integer Game_release
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\Game_release was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
59
     */
60
    public function updateLanguageForReleaseAka($language_id, $game_release_aka_id) {
61
        $stmt = \AL\Db\execute_query(
62
            "GameReleaseAkaDAO: UpdateLanguageForReleaseAka",
63
            $this->mysqli,
64
            "UPDATE game_release_aka SET language_id = ? WHERE id = ?",
65
            "si", $language_id, $game_release_aka_id
66
        );
67
68
        $stmt->close();
69
    }
70
71
    /**
72
     * Insert new AKA for release
73
     *
74
     * @param integer Game_release_id
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\Game_release_id was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
75
     * @param varchar aka_name
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\aka_name was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
76
     * @param char language_id
0 ignored issues
show
Bug introduced by
The type AL\Common\DAO\language_id was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
77
     *
78
     */
79
    public function addAkaForRelease($game_release_id, $name, $language_id) {
80
        $stmt = \AL\Db\execute_query(
81
            "GameReleaseAkaDAO: AddAkaForRelease",
82
            $this->mysqli,
83
            "INSERT INTO game_release_aka (game_release_id, name, language_id) VALUES (?,?,?)",
84
            "iss", $game_release_id, $name, $language_id
85
        );
86
87
        $stmt->close();
88
    }
89
90
     /**
91
     * Delete an AKA for a release
92
     *
93
     * @param integer Game_release_aka_id
94
     * @param integer Game_release_id
95
     *
96
     */
97
    public function deleteAkaForRelease($game_release_aka_id, $game_release_id) {
98
        $stmt = \AL\Db\execute_query(
99
            "GameReleaseAkaDAO: DeleteAkaForRelease",
100
            $this->mysqli,
101
            "DELETE FROM game_release_aka WHERE id = ? AND game_release_id = ?",
102
            "ii", $game_release_aka_id, $game_release_id
103
        );
104
105
        $stmt->close();
106
    }
107
}
108