itlessons/php-database 问题修复 & 功能扩展

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

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

itlessons/php-database

最新稳定版本:0.0.1

Composer 安装命令:

composer require itlessons/php-database

包简介

PHP Database

README 文档

README

Very simple database toolkit for PHP, providing simple pdo wrapper connection and query builder. It currently supports MySQL. Сreated for the study. But you can use it in real projects. Сode taken from Laravel Database Layer and simplified.

Usage

First, create a new manager instance.

use Database\Manager;

$manager = new Manager;

$manager->addConnection([
    'dsn' => 'mysql:dbname=testdb;host=127.0.0.1',
    'username' => 'root',
    'password' => null,
    'options' => [] // pdo driver options 
]);

Once the Manager instance has been registered. You may use it like so:

Using Connection

$conn = $manager->getConnection();
$data = $conn->queryAll('select * from users where id in (?,?,?)', 1, 2, 3);
// $data -> [['id' => 1, 'name' => 'joe'], ...]

$conn->exec('insert into users (id, name) values (?, ?)', 1, 'joe'));

$conn->execBatch(file_get_contents('file_with_queries.txt'));

Using The Query Builder

$data = $manager
            ->query('users')
            ->select('*')
            ->whereIn('id', [1,2,3])
            ->execute();

// $data -> [['id' => 1, 'name' => 'joe'], ...]


$data = $manager
            ->query('users')
            ->update(['votes' => 2])
            ->where('id', 1)
            ->toSql();
// $data -> ['update `user` set `votes` = ? where `id` = ?',[2,1]]
            
$data = $manager
          ->query('users')
          ->insert([
              ['email' => 'john@example.com', 'votes' => 0],
              ['email' => 'john1@example.com', 'votes' => 1]
          ])->execute();

More about query builder see in QueryBuilderTest

Installation

The recommended way to install php-database is through Composer. Just create a composer.json file and run the php composer.phar install command to install it:

{
    "require": {
        "itlessons/php-database": "*"
    }
}

Alternatively, you can download the php-database.zip file and extract it.

Resources

You can run the unit tests with the following command:

$ cd path/to/php-database/
$ composer.phar install
$ phpunit

Links

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固