34 lines
644 B
PHP
Executable file
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);
|
|
}
|
|
}
|
|
|
|
?>
|