# EasyDB **Repository Path**: ligan0404/easy-db ## Basic Information - **Project Name**: EasyDB - **Description**: 这是一个简单的mysql数据库操作包,支持连接池以及断线重连 - **Primary Language**: PHP - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-21 - **Last Updated**: 2021-11-26 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 介绍 这是一个简单的mysql数据库,redis操作包,支持连接池以及断线重连,依赖 Swoole ConnectionPool PDOPool/RedisPool,Medoo框架语法。 This is a simple MySQL database operation package, support connection pool and disconnection reconnection # 安装 ``` composer require ligan/easy-db ``` # 数据库使用 ## 配置 ```php $config = array( 'host' => "127.0.0.1", 'port' => 3306, 'database' => 'tpshop', 'username' => 'root', 'password' => '123456', 'charset' => 'utf8mb4', 'unixSocket' => null, 'options' => [ PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, ], 'size' => 10 ); $db = new \EasyDB\Db\EasyPdo($config,"master"); ``` ## 查询 ```php $db = new \EasyDB\Db\EasyPdo(`配置`,"master"); $db->get("test", "*"); ``` ## 新增 ```php $db = new \EasyDB\Db\EasyPdo(`配置`,"master"); $db->insert("test", ["name" => "test"]); ``` ## 编辑 ```php $db = new \EasyDB\Db\EasyPdo(`配置`,"master"); $db->update("test", ["name" => "test2"], ["id" => 1]); ``` ## 删除 ```php $db = new \EasyDB\Db\EasyPdo(`配置`,"master"); $db->delete("test", ["id" => 1]); ``` > 具体更多的操作方法可参考官方文档:https://medoo.lvtao.net/ # Redis使用 ## 配置 ```php $conf = [ 'host' => 'localhost', 'port' => 6379, 'auth' => '7GNR8pI5LOlh', 'db_index' => 15, 'time_out' => 3, 'size' => 1, ]; $redis = new \EasyDB\RedisDb\EasyRedis($conf, "master"); ``` ## set ```php $redis = new \EasyDB\RedisDb\EasyRedis(`配置`, "master"); $redis->set('key',"test"); ``` ## get ```php $redis = new \EasyDB\RedisDb\EasyRedis(`配置`, "master"); $redis->get('key'); ``` > 具体更多的操作方法可参考官方文档:http://redis.cn/commands.html