2017 © Pedro Peláez
 

library db

database

image

test-lin/db

database

  • Thursday, July 12, 2018
  • by test-lin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 32 % Grown

The README.md

数据库

环境

  • php >= 7.0
  • mysqli 或 pdo 支持
  • composer

配置

$config = [
    'db_type' => 'mysqli', // mysqli or pdo
    'mysqli' => [
        'host' => '127.0.0.1',
        'port' => 3306,
        'username' => 'root',
        'password' => 'root',
        'dbname' => 'test'
    ],
    'pdo' => [
        'host' => '127.0.0.1',
        'port' => 3306,
        'username' => 'root',
        'password' => 'root',
        'dbname' => 'test'
    ]
];

操作

所有驱动均支持以下方法, (*1)

  • select(String $sql);
    说明:查询多条数据
    参数:执行的 sql
    返回:查询成功,返回 二维数组数据;否则返回 false;, (*2)

  • find(String $sql);
    说明:查询一条数据
    参数:执行的 sql
    返回:查询成功,返回 关联数组数据;否则返回 false;, (*3)

  • getField(String $sql, String $field = null);
    说明:取一个字段的值
    参数:执行的 sql,指定字段
    返回:查询成功,返回 字段数据;否则返回 false;, (*4)

  • insert(String $table, array $data);
    说明:添加数据到数据表
    参数:表名,添加到数据库的数据
    返回:bool, (*5)

  • update(String $table, array $data, $where);
    说明:更新数据表数据
    参数:表名,要修改的数据,条件
    返回:bool, (*6)

  • delete(String $table, $where);
    说明:删除数据表数据
    参数:表名,条件
    返回:bool, (*7)

  • beginTransaction();
    说明:开启事务
    返回:null, (*8)

  • rollback();
    说明:事务回滚
    返回:null, (*9)

  • commit();
    说明:提交事务
    返回:null, (*10)

实例

$db_type = $config['db_type'];
$db = new Testlin\Db\Db($db_type, $config[$db_type]);

The Versions

12/07 2018

dev-php5.6

dev-php5.6

database

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

by Avatar jani

13/05 2018

dev-master

9999999-dev

database

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

by Avatar jani