reptily/db
Composer 安装命令:
composer require reptily/db
包简介
DB interface for MySQL
README 文档
README
convenient library to work with mysql for php
Install for composer
composer require reptily/db
Initialization module
require "./vendor/autoload.php"; $config = [ "host" => "localhost", "login" => "root", "pwd" => "*******", "db" => "php_db_test" ]; $DB = new \openWeb\DB($config);
Create table
$table = [ "id" =>[ "type"=>"int", "count"=>11, "isNull"=>false, "autoIncrement"=>true ], "name"=>[] ]; $DB->Create("account",$table);
Insert value
$DB->account->Insert(["name"=>"user"]);
Select all rows and output to array
$row=$DB->account->Select()->getArray(); print_r($row);
Select all rows and output to json string
echo $DB->account->Select()->getJson();
Select table account only id colum
echo $DB->account->where(["id" => 1])->Select()->getJson();
Select table account only id colum
echo $DB->account->field(["id"])->Select()->getJson();
Select table account and where id = 1 and id = 3
echo $DB->account->where('or',["id" => 1],["id" => 3])->Select()->getJson();
Select table account only id colum and where id = 1
echo $DB->account->field(["name"])->where(["id" => 1])->Select()->getJson();
Select table account id and name colum and where id = 1
echo $DB->account->field(["id","name"])->where(["id" => 1])->Select()->getJson();
Select table account where id more 1
echo $DB->account->where("id > 1")->Select()->getJson();
Inner table blog
echo $DB->account->inner("blog")->on("id","id")->Select()->getJson();
Left table blog
echo $DB->account->left("blog")->on("id","id")->Select()->getJson();
Update values in table blog
$DB->blog->set(['name' => 'update'])->where(["id" => 2])->Update();
Delete values in table account
$DB->account->where(["id" => 1])->Delete()
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-06-06