承接 alexccavaco/database 相关项目开发

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

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

alexccavaco/database

Composer 安装命令:

composer require alexccavaco/database

包简介

MySQL Database Query Builder for PHP

README 文档

README

A Database Query Builder for PHP

There are four classes from where to start building: DBDelete, DBInsert, DBSelect and DBUpdate

These are assigned to equivalent MySQL queries.

Installation

  composer require alexccavaco/database

Examples

Select Query:

  $r=DBSelect::from('table')
    ->select('*')
    ->where('column1 = ?', $data1)
    ->where('column2 = ?', $data2)
    ->orderBy('name')
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

Delete Query:

  $r=DBUpdate::table('table')
    ->set('column','?',$param)
    ->setAll(['column'=>$param,'anotherCol'=>$param2])
    ->where('column = ?','data')
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

Insert Query:

  $r=DBInsert::into('table')
    ->value('column1',$param1)
    ->value('column2',$param2,true) //The third parameter if true automatically sets On Duplicate Update
    ->values(['column'=>$param])
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

Delete Query:

  $r=DBDelete::from('table')
    ->where('column = ?','data')
    ->limit(2)
    ->run($db);

  $r->fetch(\PDO::FETCH_ASSOC);

Complex Queries can be created, using joins, having... but these are just a few examples.

Database Class

With the package comes a Database Class. This class sets some attributes by default (such as the use of exceptions for errors and emulate prepares) and its constructor eases the setting of charsets and timezones for mysql.

Two functions come with it:

  • prepRun - Eases the preparation of statements, preparing and executing them before returning
  • logStatement - Receives a PSR Logger and a log type to log every query and parameters (for debugging)

This class is completely optional.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-05-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固