treewide: swap all uses of bindParam with bindValue
This causes complaints and warnings when used with functions generating values instead of already bound variables. Nowhere do we rely on the arguments being passed by reference.
This commit is contained in:
@@ -20,16 +20,16 @@ class UserManager {
|
||||
public function setupUser(string $uname, int $groups = 0): void {
|
||||
$query = 'INSERT INTO users (uname, groups) VALUES (:uname, :groups)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function updateFlags(string $uname, int $flags): void {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $flags, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':groups', $flags, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
public function addGroup(string $uname, int $group): void {
|
||||
@@ -53,15 +53,15 @@ class UserManager {
|
||||
public function setGroups(string $uname, int $groups): void {
|
||||
$query = 'SELECT * FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
$row = $statement->fetch();
|
||||
|
||||
if ($row) {
|
||||
$query = 'UPDATE users set groups=:groups WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':groups', $groups, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
} else {
|
||||
$this->setupUser($uname, $groups);
|
||||
@@ -94,7 +94,7 @@ class UserManager {
|
||||
public function getUsergroups(string $uname): int {
|
||||
$query = 'SELECT groups FROM users WHERE uname=:uname LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$row = $statement->fetch();
|
||||
|
||||
@@ -39,7 +39,7 @@ class DBActivity implements Activity {
|
||||
public function getEventByID(int $id): SimpleEvent {
|
||||
$query = 'SELECT * FROM events WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbEvent = $statement->fetch();
|
||||
|
||||
@@ -68,8 +68,6 @@ class Door {
|
||||
* @return DoorStatus[]
|
||||
*/
|
||||
public function getEntriesAfter(\DateTimeImmutable $startTime): array {
|
||||
$timestamp = $startTime->getTimestamp();
|
||||
|
||||
$query = '
|
||||
SELECT
|
||||
time,
|
||||
@@ -79,7 +77,7 @@ class Door {
|
||||
ORDER BY time DESC
|
||||
';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':startTime', $timestamp, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':startTime', $startTime->getTimestamp(), \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$result = array_map(
|
||||
@@ -124,15 +122,15 @@ class Door {
|
||||
$firstValidTime = time() - 60 * 60 * 24 * self::DAYS_OF_DOOR_HISTORY;
|
||||
$query = 'DELETE FROM door WHERE time < :firstValid';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':firstValid', $firstValidTime, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':firstValid', $firstValidTime, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
public function createEvent(\DateTimeImmutable $time, bool $open): void {
|
||||
$query = 'INSERT INTO door(time, open) VALUES (:time, :open)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':time', $time->getTimestamp(), \PDO::PARAM_INT);
|
||||
$statement->bindParam(':open', $open, \PDO::PARAM_BOOL);
|
||||
$statement->bindValue(':time', $time->getTimestamp(), \PDO::PARAM_INT);
|
||||
$statement->bindValue(':open', $open, \PDO::PARAM_BOOL);
|
||||
$statement->execute();
|
||||
|
||||
$this->removeOld();
|
||||
|
||||
@@ -47,8 +47,8 @@ class MOTD {
|
||||
$query = 'INSERT INTO motd(title, content) VALUES (:title, :content)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, \PDO::PARAM_STR);
|
||||
$statement->bindParam(':content', $content, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':title', $title, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':content', $content, \PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
@@ -88,7 +88,7 @@ class MOTD {
|
||||
LIMIT :limit
|
||||
';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':limit', $limit, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':limit', $limit, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$result = array_map(
|
||||
|
||||
@@ -36,7 +36,7 @@ class ProjectManager {
|
||||
public function getByID(int $id): ?Project {
|
||||
$query = 'SELECT * FROM projects WHERE id=:id LIMIT 1';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
$dbProj = $statement->fetch();
|
||||
@@ -58,7 +58,7 @@ class ProjectManager {
|
||||
public function getByOwner(string $uname): array {
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':uname', $uname, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$projectIDs = $statement->fetchAll();
|
||||
@@ -68,7 +68,7 @@ class ProjectManager {
|
||||
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->bindValue(':id', $id, \PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
foreach ($statement->fetchAll() as $dbProj) {
|
||||
@@ -91,7 +91,7 @@ class ProjectManager {
|
||||
public function getProjectMembers(int $id): array {
|
||||
$query = 'SELECT * FROM projectmembers WHERE projectid=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$members = [];
|
||||
@@ -115,7 +115,7 @@ class ProjectManager {
|
||||
public function getProjectOwner(int $id): array {
|
||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->bindValue(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$dbOwner = $statement->fetch();
|
||||
|
||||
Reference in New Issue
Block a user