# database **Repository Path**: ziyoren/database ## Basic Information - **Project Name**: database - **Description**: A database component based on meboo, which can run in PHP FPM and swoole environment, and support database connection pool in swoole. - **Primary Language**: PHP - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-03-27 - **Last Updated**: 2022-03-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## 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)