定制 mac/database 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mac/database

Composer 安装命令:

composer require mac/database

包简介

Simple PDO helper to perform most common database operations

README 文档

README

Build Status

PDO Helper implements some common database operations

Installation

Here is composer.json example:

{
    "require": {
        "mac/database": "x"
    },
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/mac2000/database"
        }
    ]
}

Usage example

First of all you need some database connection:

$db = new Database(new PDO('mysql:host=localhost;dbname=example', 'root', 'root'));
// or for test purposes
$db = new Database(new PDO('sqlite::memory:'));

Retrieve all/one row(s):

$users = $db->all("SELECT * FROM users");
$user = $db->one("SELECT * FROM users WHERE user_id = :user_id", array('user_id' => 1));

Retrieve computed value:

$count = $db->cell("SELECT COUNT(*) FROM users");

Modify data:

$lastInsertId = $db->execute(
    "INSERT INTO users (first_name, last_name, age) VALUES(:first_name, :last_name, :age)",
    array('first_name' => 'Hello', 'last_name' => 'World', 'age' => 9)
);

$rowsAffectedCount = $db->execute(
    "DELETE FROM users WHERE user_id = :user_id",
    array('user_id' => 2)
);

Run tests

Look at .travis.yml there is few tests that are runned:

vendor/bin/phpunit
vendor/bin/phpcpd src tests
vendor/bin/phpmd src,tests text cleancode, codesize, controversial, design, naming, unusedcode
vendor/bin/phpcs --standard=psr2 src tests

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-03-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固