Blackbird
NoSQL Database Engine by Orseolo.hu
Json alapú flat file noSQL adatbázismotor PHP program,
mely könnyedén beépíthető tetszőleges új vagy meglévő projektbe.
Json alapú flat file noSQL adatbázismotor PHP program,
mely könnyedén beépíthető tetszőleges új vagy meglévő projektbe.
Fedezd fel a jövő adatbázis-kezelését!
A Blackbird nem csupán egy adatbázis - ez a gyorsaság, biztonság és rugalmasság tökéletes egyensúlya.
include "library/blackbird.php";
$bDb = new Blackbird("testDb");
$bDb->use("Test");
$bDb->dropTableIfExists("user");
$bDb->truncate("user");
if (!$bDb->checkTableExists("user")) {
$bDb->createTableIfNotExists("user", [
'id' => ['type' => "int", 'autoIncrement' => true],
'status' => ['type' => "bool", 'defaultValue' => true],
'tsCreate' => ['type' => "dateTime"],
'tsModify' => ['type' => "dateTime"],
'name' => ['type' => "text", 'length' => 255],
'email' => ['type' => "email",],
'phone' => ['type' => "text", 'length' => 25],
'birthDate' => ['type' => "date"],
'point' => ['type' => "int"],
]);
$bDb->insert("user", [
//'status' => true,
'tsCreate' => date("Y-m-d H:i:s"),
'tsModify' => date("Y-m-d H:i:s"),
'name' => "Teszt Elek",
'email' => "teszt.elek@domain.tld",
'phone' => "+36 20 xxx xxxx",
'birthDate' => "1983-12-19",
'point' => 83,
]);
$bDb->insert("user", [
//'status' => true,
'tsCreate' => date("Y-m-d H:i:s"),
'tsModify' => date("Y-m-d H:i:s"),
'name' => "Teszt Elek",
'email' => "teszt.elek@domain.tld",
'phone' => "+36 20 xxx xxxx",
'birthDate' => "1983-12-19",
'point' => 50,
]);
$bDb->insert("user", [
//'status' => true,
'tsCreate' => date("Y-m-d H:i:s"),
'tsModify' => date("Y-m-d H:i:s"),
'name' => "Teszt Elek",
'email' => "teszt.elek@domain.tld",
'phone' => "+36 20 xxx xxxx",
'birthDate' => "1983-12-19",
'point' => 18,
]);
$bDb->update("user",[
'tsModify' => date("Y-m-d H:i:s"),
'name' => "Minta Példa",
'email' => "email@domain.tld",
'phone' => "+36 12 345 67890",
'birthDate' => "2000-01-01",
],[["id¤=¤2"]]);
$bDb->update("user",[
'tsModify' => date("Y-m-d H:i:s"),
'name' => "Teszt Elek",
'email' => "email@domain.tld",
'phone' => "+36 12 345 67890",
'birthDate' => "2011-12-13",
],[["id¤=¤3"]]);
}
if ($bDb->checkFieldExists("user","enabled")) { /* do anything */ }
# SELECT id,name,phone FROM user WHERE id = 1;
$result = $bDb->SELECT("user",[["id¤=¤1"]],"id,name,phone")->getResult();
# SELECT id,name,phone FROM user WHERE id = 1 OR id = 2;
$result = $bDb->SELECT("user",[["id¤=¤1"],["id¤=¤2"]],"id,name,phone")->getResult();
# SELECT * FROM user WHERE (id = 1 AND status = "false") OR id = 2;
$result = $bDb->SELECT("user",[["id¤=¤1","status¤=¤".false],["id¤=¤2"]])->getResult();
# SELECT id,name,birthDate FROM user WHERE birthDate < "2001-01-01";
$result = $bDb->SELECT("user",[["birthDate¤<¤2001-01-01"]],"id,name,birthDate")->getResult();
# SELECT id,name,birthDate FROM user WHERE birthDate between "2001-01-01" AND "2005-12-31" ORDER BY birthDate DESC LIMIT 10,20;
$result = $bDb->SELECT("user",[["birthDate¤between¤2001-01-01¤2005-12-31"]],"id,name,birthDate")->orderBy("birthDate","desc")->limit(10,20)->getResult();
# SELECT * FROM user WHERE name LIKE '%elek%';
$result = $bDb->SELECT("user",[["name¤like¤%elek%"]])->getResult();
# SELECT count(*) FROM user WHERE status = 1 AND point BETWEEN 40 AND 80;
# A getResult() metódus true paramétere megadja, hogy a válaszba a runtime értéket is visszaadja.
$result = $bDb->count("user",[["status¤=¤1","point¤between¤40¤80"]])->getResult(true);