Examples
Insert array(s):
include("noneDB.php");
$noneDB = new noneDB;
$data = array("username"=>"orhanayd", "password"=>"123456");
/**
* $data will be insert to your_dbname
* you can insert multiple array like this;
* $data = array(
* array("username"=>"orhanayd", "password"=>"123456"),
* array("username"=>"kemalataturk", "password"=>"123456789")
* );
*/
$insert = $noneDB -> insert("your_dbname", $data);
echo json_encode($insert);
Result example:
{
"n": 1
}
Find Records:
(Find command is like "SELECT" query in sql)
include("noneDB.php");
$noneDB = new noneDB();
/**
* you can find like this;
* array("username"=>"orhan")
* or
* array("key"=>[2,4,5])
* returns only 0,2,3 keys
*/
$filter = array("username"=>"orhanayd");
$test = $noneDB -> find("your_dbname", $filter, false);
echo json_encode($test);
Result example:
[
{
"username": "orhanayd",
"password": "123456",
"key": 0
}
]
Update Record(s)
include("noneDB.php");
$noneDB = new noneDB();
/**
* array(
* array of one => search criteria
* array("set"=> new values or new keys)
* )
*
* note: you can update by key for example;
* array(
* array("key"=>[0,2,3]),
* array("set"=>array("newkey"=>"newvalue", "oldkey"=>"newvalue"))
* )
* it will only update keys 0,2,3.
*
*/
$update = array(
array("username"=>"orhanayd"),
array("set"=>array(
"password"=>"123456789"
))
);
$test = $noneDB -> update("your_dbname", $update);
echo json_encode($test);
Result example:
{
"n": 1
}
Delete Record(s)
include("noneDB.php");
$noneDB = new noneDB();
/**
* you can delete like this;
* array("username"=>"orhan")
* or
* array("key"=>[2,4,5])
* just delete only 0.2,3 keys
*/
$filter = array("username"=>"orhanayd");
$test = $noneDB -> delete("your_dbname", $filter);
echo json_encode($test);
Result example:
{
"n": 1
}
Additional features:
Extract a slice of the array (Like “LIMIT” query in sql):
include("noneDB.php");
$noneDB = new noneDB();
$filter = array("username"=>"orhanayd");
$test = $noneDB -> find("your_dbname", $filter, false);
/**
* $test is result array
* 10 is how much limit for result
*/
$test = $noneDB -> limit($test, 10); // Limit
/**
* will returns only 10 array.
*/
echo json_encode($test);