1
0
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
2432ccdcf1 Update 2024-06-09 18:08:49 +02:00
3af018bfd1 Database change 2024-06-09 18:08:35 +02:00
7 changed files with 12 additions and 21 deletions

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
functions/age.php Normal file → Executable file
View file

View file

@ -1,44 +1,34 @@
<?php
function sql($query, $array, $method = '') {
function sql($query, $array = [], $method = null) {
global $sql;
try {
$prepare = $sql->prepare($query);
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);
$data = $prepare->fetch(PDO::FETCH_ASSOC);
return $data;
} elseif($method == 'insert') {
foreach($array AS $data => $value) {
$prepare->bindValue(':'.$data, $value);
}
$prepare->execute();
return $value;
return $prepare->fetch();
} else {
$prepare = $sql->prepare($query);
$prepare->execute($array);
return $prepare;
return $prepare->fetchAll();
}
} catch(Exception $e) {
throw($e);
}
}
?>

0
page-errors.php Normal file → Executable file
View file

View file

@ -27,6 +27,7 @@
$config_sitelang = 'sv';
$database_host = null;
$database_port = null;
$database_name = null;
$database_user = null;
$database_pass = null;

View file

@ -37,7 +37,7 @@
if(!empty($database_host) AND !empty($database_name) AND !empty($database_user) AND !empty($database_pass)) {
try {
$sql = new PDO('mysql:host='.$database_host.';dbname='.$database_name, $database_user, $database_pass);
$sql = new PDO('pgsql:host='.$database_host.';port='.$database_port.';dbname='.$database_name.';user='.$database_user.';password='.$database_pass);
$sql->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}