mikehenrty/thin-pdo-wrapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mikehenrty/thin-pdo-wrapper

最新稳定版本:1.0.1

Composer 安装命令:

composer require mikehenrty/thin-pdo-wrapper

包简介

A simple database abstraction for using PDO with MySQL, Postgres, and SQLite.

README 文档

README

A simple database client utilizing PHP PDO.

Advantages

  • Maintains at most one connection to slave DB and one to master DB per request.
  • Automatically uses slave connection for data retrieval, master for writes.
  • Randomized slave connection, with automatic fallback to master if no slaves exist.
  • Enforces data sanitization (using PDO prepared statements and bind parameters).
  • Catches all errors, and writes them to error log if configured to do so.
  • Automatic timestamps for creates and updates
  • Handles multiple inserts with a single query.
  • Fallback to custom queries if one needs to do a join or second order query.
  • Deals exclusively with associative arrays for input/output

Configuration

Master

  $pdo->configMaster(
    'myhostname.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );

Slaves (optional)

  $pdo->configSlave(
    'myhostname1.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );

  $pdo->configSlave(
    'myhostname2.example',
    'my_database_name',
    'my_database_user',
    'my_database_password',
    'my_database_port' // optional
  );
  // etc

Examples

Selecting

  $results = PDOWrapper::instance()->select('post', array('thread_id'=>$thread_id));
  $results = PDOWrapper::instance()->select('thread', array('open'=>0), $limit+1, $start, array('favs'=>'DESC'));

Inserting

  $invite_id = PDOWrapper::instance()->insert('invite', array(
    'user_id' => $user_id,
    'text' => $text,
    'invite_key' => $invite_key
  ));

Complex Queries with bind parameters

  $post = PDOWrapper::instance()->queryFirst('
    SELECT invite.*, user.name FROM invite
    LEFT JOIN user ON user.id=invite.user_id
    WHERE invite_key=:invite_key
  ', array(':invite_key'=>$invite_key));

统计信息

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

GitHub 信息

  • Stars: 68
  • Watchers: 11
  • Forks: 31
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-04-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固