include the file
require 'synskuel.php';
Connect to the database
Synskuel::connect(host, database, user, password [, options(array)]);
$options = [PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_NUM];
Synskuel::connect('127.0.0.1', 'database', 'root', 'superpass', $options);
Synskuel::query(query [, params(array), success(callback), error(callback)];
SELECT example :
// Callbacks are optionals
Synskuel::query("SELECT * FROM table WHERE id=?", [3], function($res){
print_r($res->fetchAll());
}, function($err){
print_r($err);
});
INSERT example :
// Callbacks are optionals
Synskuel::query("INSERT INTO table (name, lastname) VALUES(?,?)", ['John', 'Doe']);
UPDATE/DETE example :
// Callbacks are optionals
Synskuel:: query("UPDATE table SET name=? WHERE id=?", ['Jane', 1]):
Synskuel:: query("DELETE FROM table WHERE id=?", [1]):
COUNT example :
$number = Synskuel::query("SELECT COUNT(*) FROM table");
echo $number;
// OR
Synskuel::query("SELECT COUNT(*) FROM table ", [], function($number){
echo $number;
});
CHECK if a record exists :
Synskuel::exists("SELECT COUNT(*) FROM table WHERE name=? ", ['Jane'], function(){
echo " Jane is in the database !";
}, function() {
echo "Jane is not in the database !";
});
Synskuel::errors();
// Default file : synskuel.log
Synskuel::logs();
// Custom file :
Synskuel::logs("yourfile.ext);