💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Mysql具体使用 **异步mysql连接池** 例子可参考ServerMysqlTest.php文件 ## 创建表 示例: ```php yield $this->mysql_pool->dbQueryBuilder->coroutineSend(null, " CREATE TABLE IF NOT EXISTS `MysqlTest` ( `peopleid` smallint(6) NOT NULL AUTO_INCREMENT, `firstname` char(50) NOT NULL, `lastname` char(50) NOT NULL, `age` smallint(6) NOT NULL, `townid` smallint(6) NOT NULL, PRIMARY KEY (`peopleid`), UNIQUE KEY `unique_fname_lname`(`firstname`,`lastname`), KEY `fname_lname_age` (`firstname`,`lastname`,`age`) ) ; "); ``` ## 删除表(直接执行sql语句) 示例: ```php yield $this->mysql_pool->dbQueryBuilder->coroutineSend(null, " DROP TABLE `MysqlTest`; "); ``` ## 插入 示例: ```php $value = yield $this->mysql_pool->dbQueryBuilder->insert('MysqlTest') ->option('HIGH_PRIORITY') ->set('firstname', 'White') ->set('lastname', 'Cat') ->set('age', '25') ->set('townid', '10000') ->coroutineSend(); ``` ## 替换 示例: ```php $value = yield $this->mysql_pool->dbQueryBuilder->replace('MysqlTest') ->set('firstname', 'White') ->set('lastname', 'Cat') ->set('age', '26') ->set('townid', '10000') ->coroutineSend(); ``` ## 修改 示例: ```php $value = yield $this->mysql_pool->dbQueryBuilder->update('MysqlTest') ->set('age', '20') ->where('townid', 10000) ->coroutineSend(); ``` ## Update 字段值的增加/减少 示例: ```php $value = $this->db->update('MysqlTest') ->set("score","score+1",false) ->where('townid', 10000)->coroutineSend(); ``` ## 查询 示例: ```php $value = yield $this->mysql_pool->dbQueryBuilder->Select('*') ->from('MysqlTest') ->where('townid', 10000, "<") ->orderBy("townid","desc") ->limit(10) ->coroutineSend(); ``` ## 删除 示例: ```php $value = yield $this->mysql_pool->dbQueryBuilder->delete() ->from('MysqlTest') ->where('townid', 10000) ->coroutineSend(); ``` ## 返回值 [Mysql返回值说明](mysql返回值.md)