PHP code example of reptily / db
1. Go to this page and download the library: Download reptily/db library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
reptily / db example snippets
$config = [
"host" => "localhost",
"login" => "root",
"pwd" => "*******",
"db" => "php_db_test"
];
$DB = new \openWeb\DB($config);
$table = [
"id" =>[
"type"=>"int",
"count"=>11,
"isNull"=>false,
"autoIncrement"=>true
],
"name"=>[]
];
$DB->Create("account",$table);
$DB->account->Insert(["name"=>"user"]);
$row=$DB->account->Select()->getArray();
print_r($row);
echo $DB->account->Select()->getJson();
echo $DB->account->where(["id" => 1])->Select()->getJson();
echo $DB->account->field(["id"])->Select()->getJson();
echo $DB->account->where('or',["id" => 1],["id" => 3])->Select()->getJson();
echo $DB->account->field(["name"])->where(["id" => 1])->Select()->getJson();
echo $DB->account->field(["id","name"])->where(["id" => 1])->Select()->getJson();
echo $DB->account->where("id > 1")->Select()->getJson();
echo $DB->account->inner("blog")->on("id","id")->Select()->getJson();
echo $DB->account->left("blog")->on("id","id")->Select()->getJson();
$DB->blog->set(['name' => 'update'])->where(["id" => 2])->Update();
$DB->account->where(["id" => 1])->Delete()