承接 sinri/sinri-database-agent 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sinri/sinri-database-agent

Composer 安装命令:

composer require sinri/sinri-database-agent

包简介

Provide a old-style alike quick SQL handler for PHP.

README 文档

README

Packagist Version Badge Packagist Packagist

Provide a old-style alike quick SQL handler for PHP. With this toolkit developers could be free from writing fundamental code for database.

Composer

composer require sinri/sinri-database-agent

Usage

  1. Include the autoload.php into your PHP project.
  2. Declare what you need for convenience.
// PDO
use sinri\SinriDatabaseAgent\SinriPDO;
$db=new SinriPDO($params);
// MySQLi
use sinri\SinriDatabaseAgent\SinriMySQLi;
$db=new SinriMySQLi($params);
  1. General Method

If the following SQL SELECT X,Y FROM T WHERE KEY>0; refers to this records:

KEY X Y
1 x1 y1
2 x2 y2
$sql="SELECT X,Y FROM T WHERE KEY>0;";

$db->getAll($sql);
// return [["X"=>"x1","Y"=>"y1"],["X"=>"x2","Y"=>"y2"]]

$db->getRow($sql);
// return ["X"=>"x1","Y"=>"y1"]

$db->getCol($sql);
// return ["x1","x2"]

$db->getOne($sql);
// return "x1"

If you need to do some modification.

$sql="INSERT INTO...";
$db->insert($sql);
// return the last inserted record's PK value.

$sql="UPDATE ...";// or DELETE, etc.
$db->exec($sql);
// return affected row count, or FALSE on failure.

You may want to use transactions.

$db->beginTransaction();

// do some work

$db->inTransaction();
// return if this line is in transaction

if($has_error){
    $db->rollBack();
}else{
    $db->commit();
}

For Developers

  • Use Code Rule PSR2, just run ./PSR2.sh before commit and push if phpcs and phpcbf is correctly installed.
  • Run php test/test.php to do Unit Test after correcting test\config.php settings.

Check

phpcs --report=full --standard=PSR2 --ignore=vendor . 
phpcs --report=summary --standard=PSR2 --ignore=vendor . 

Correct

phpcbf --report=full --standard=PSR2 --ignore=vendor .

License

SinriDatabaseAgent is published under MIT License.

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-03-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固