mtchabok/database
Composer 安装命令:
composer require mtchabok/database
包简介
PHP PDO Database Class for handling Databases
README 文档
README
PHP PDO Database Class for handling Databases.
- unlimited managment connection to databases
- objective query control
- fast execute query
- php pdo support
- support add/edit variable`s in queries
- subqueries supported
- pdo (mysql, sqlsrv) support
- auto generate query
- database/table/field name control
Installation
This package is listed on Packagist.
composer require mtchabok/database
How To Usage
Create Connection Object
use \Mtchabok\Database\Connection; $connection = new Connection('mysql:host=localhost;dbname=test;charset=utf8', 'root',''); $connection = Connection::newConnection('mysql:host=localhost;dbname=test;charset=utf8', 'root',''); $connection = (new Connection()) ->setDriver(Connection::DRIVER_MYSQL) ->setServer('localhost') ->setDatabase('test') ->setUser('root') ->setPass('') ->setCharset(Connection::CHARSET_UTF8) ; class my_connection extends Connection { protected $_driver = Connection::DRIVER_MYSQL; protected $_server = 'localhost'; protected $_database = 'test'; protected $_user = 'root'; protected $_charset = Connection::CHARSET_UTF8; } $connection = new my_connection(); $connection = new Connection\Mysql(); $connection->setDatabase('test');
Create Select/Insert/Update/Delete Query Object
use Mtchabok\Database\Select; use Mtchabok\Database\Insert; use Mtchabok\Database\Update; use Mtchabok\Database\Delete; $qSelect = $connection->newSelect('person'); $qInsert = $connection->newInsert('person'); $qUpdate = $connection->newUpdate('person'); $qDelete = $connection->newDelete('person'); $qSelect = (new Select('person'))->setConnection($connection); $qInsert = (new Insert('person'))->setConnection($connection); $qUpdate = (new Update('person'))->setConnection($connection); $qDelete = (new Delete('person'))->setConnection($connection); $qSelect = (Select::newSelect('person'))->setConnection($connection);
Execute Query
$qSelect->setField(['id', 'name', 'mobile']) ->addWhere('%mohammad%', 'LIKE', 'name') ->setOrderBy('id', 'DESC') ; $result = $qSelect->fetchAllObject(); // return array of objects
For More Usage Documentation, Use This Database Package By IDE
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-16