id/database.php

27 lines
471 B
PHP
Raw Normal View History

2023-11-19 12:24:38 +00:00
<?php
// Functions for interacting with the database. Requires PDO is initialised at $pdo.
function db_execute($sql, $variables=[]) {
global $pdo;
$stmt = $pdo->prepare($sql);
$stmt->execute($variables);
return $stmt->fetch();
}
2024-03-02 12:41:57 +00:00
function db_execute_all($sql, $variables=[]) {
global $pdo;
$stmt = $pdo->prepare($sql);
$stmt->execute($variables);
return $stmt->fetchAll();
}
2023-11-19 12:24:38 +00:00
function db_query($sql) {
global $pdo;
return $pdo->query($sql);
}