Compare commits
2 commits
144431b125
...
2432ccdcf1
Author | SHA1 | Date | |
---|---|---|---|
2432ccdcf1 | |||
3af018bfd1 |
7 changed files with 12 additions and 21 deletions
0
LICENSE
Normal file → Executable file
0
LICENSE
Normal file → Executable file
0
README.md
Normal file → Executable file
0
README.md
Normal file → Executable file
0
functions/age.php
Normal file → Executable file
0
functions/age.php
Normal file → Executable 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
0
page-errors.php
Normal file → Executable file
|
@ -27,6 +27,7 @@
|
|||
$config_sitelang = 'sv';
|
||||
|
||||
$database_host = null;
|
||||
$database_port = null;
|
||||
$database_name = null;
|
||||
$database_user = null;
|
||||
$database_pass = null;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue