1
0
Fork 0
template/functions/sql.php
2024-06-09 18:08:35 +02:00

34 lines
644 B
PHP
Executable file

<?php
function sql($query, $array = [], $method = null) {
global $sql;
try {
if($method == 'count') {
$prepare = $sql->query($query);
$prepare->execute($array);
$data = $prepare->fetchColumn();
return $data;
} elseif($method == 'insert') {
$prepare = $sql->prepare($query);
$prepare->execute($array);
} elseif($method == 'fetch') {
$prepare = $sql->query($query);
$prepare->execute($array);
return $prepare->fetch();
} else {
$prepare = $sql->prepare($query);
$prepare->execute($array);
return $prepare->fetchAll();
}
} catch(Exception $e) {
throw($e);
}
}
?>