https://github.com/ziyoren/database
A database component based on meboo, which can run in PHP FPM and swoole environment, and support database connection pool in swoole.
https://github.com/ziyoren/database
Last synced: 22 days ago
JSON representation
A database component based on meboo, which can run in PHP FPM and swoole environment, and support database connection pool in swoole.
- Host: GitHub
- URL: https://github.com/ziyoren/database
- Owner: ziyoren
- License: mit
- Created: 2020-12-05T14:59:30.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-12-16T09:06:32.000Z (over 5 years ago)
- Last Synced: 2025-08-13T02:25:50.923Z (10 months ago)
- Language: PHP
- Size: 12.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A database component based on [meboo](https://github.com/catfan/Medoo), which can run in php-fpm and [swoole](https://github.com/swoole/swoole-src) environment, and support database connection pool in swoole.
## Requirement
* PHP7.1+
* PDO extension installed.
* Swoole 4.4+
## Get Started
### Install
```
$ composer require ziyoren/database
```
### update
```
$ composer update
```
### PDO Databases
```php
require 'vendor/autoload.php';
use ziyoren\Database\BaseModel; // swoole(支持数据库连接池)
//use ziyoren\Database\PDO; // 传统的php-fpm 无连接池
//For database configuration, see ziyoren\Database\DbConfig.php
$db = new BaseModel(); //swoole模式下使用
//$db = new PDO(); //php-fpm模式下使用
$db->insert('account', [
'user_name' => 'foo',
'email' => 'foo@bar.com'
]);
$data = $db->select('account', [
'user_name',
'email'
], [
'user_id' => 50
]);
echo json_encode($data);
```
### Redis pools
```php
require 'vendor/autoload.php';
use ziyoren\Database\BaseRedis;
//For Redis configuration, see /config/redis.php
$redis = new BaseRedis();
$redis->set('key', 'value');
$rst = $redis->get('key');
echo $rst; //value
```
## License
ziyoren/database is under the MIT license.
## Links
* Databases Doc: [https://medoo.in/doc](https://medoo.in/doc)
* Redis Doc: [https://github.com/phpredis/phpredis/blob/develop/README.markdown](https://medoo.in/doc)