Skip to content

Commit

Permalink
fixed: 完善test的配置文件
Browse files Browse the repository at this point in the history
  • Loading branch information
bingcool committed Jul 3, 2023
1 parent 88aa440 commit 0cbe9dc
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ return [
// 适配swoole的mysql客户端组件
'db' => function() {
$config = [
// 类型
'type' => 'mysql',
// 地址
'hostname' => '127.0.0.1',
// 数据库
Expand Down
7 changes: 5 additions & 2 deletions Test/Config/dc-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

use PhpAmqpLib\Connection\AMQPConnectionConfig;
use Test\Config\AmqpConfig;
use Swoolefy\Core\SystemEnv;

return [

'mysql_db' => [
// 类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
Expand Down Expand Up @@ -33,11 +36,11 @@
// sql执行日志条目设置,不能设置太大,适合调试使用,设置为0,则不使用
'spend_log_limit' => 30,
// 是否开启dubug
'debug' => 1
'debug' => SystemEnv::isPrdEnv() ? 0 : 1
],

'predis' => [
'scheme' => 'tcp',
'scheme' => 'tp',
'host' => '127.0.0.1',
'port' => 6379,
],
Expand Down
6 changes: 5 additions & 1 deletion Test/Config/dc-gra.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

use Swoolefy\Core\SystemEnv;

return [

'mysql_db' => [
// 类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
Expand Down Expand Up @@ -30,7 +34,7 @@
// sql执行日志条目设置,不能设置太大,适合调试使用,设置为0,则不使用
'spend_log_limit' => 30,
// 是否开启dubug
'debug' => 1
'debug' => SystemEnv::isPrdEnv() ? 0 : 1
],

'predis' => [
Expand Down
6 changes: 5 additions & 1 deletion Test/Config/dc-prd.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

use Swoolefy\Core\SystemEnv;

return [

'mysql_db' => [
// 类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
Expand Down Expand Up @@ -30,7 +34,7 @@
// sql执行日志条目设置,不能设置太大,适合调试使用,设置为0,则不使用
'spend_log_limit' => 30,
// 是否开启dubug
'debug' => 1
'debug' => SystemEnv::isPrdEnv() ? 0 : 1
],

'predis' => [
Expand Down
6 changes: 5 additions & 1 deletion Test/Config/dc-test.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<?php

use Swoolefy\Core\SystemEnv;

return [

'mysql_db' => [
// 类型
'type' => 'mysql',
// 服务器地址
'hostname' => '127.0.0.1',
// 数据库名
Expand Down Expand Up @@ -30,7 +34,7 @@
// sql执行日志条目设置,不能设置太大,适合调试使用,设置为0,则不使用
'spend_log_limit' => 30,
// 是否开启dubug
'debug' => 1
'debug' => SystemEnv::isPrdEnv() ? 0 : 1
],

'predis' => [
Expand Down
6 changes: 5 additions & 1 deletion Test/Scripts/FixedUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Test\Scripts;

use Common\Library\Db\Mysql;
use Swoolefy\Core\Application;

class FixedUser extends \Swoolefy\Script\MainCliScript
Expand All @@ -12,8 +13,11 @@ public function fixName()
var_dump('CID='.\Swoole\Coroutine::getCid());
var_dump('Script test');
sleep(4);
/**
* @var Mysql $db
*/
$db = Application::getApp()->get('db');
$result = $db->createCommand('select * from tbl_users limit 1')->queryAll();
$result = $db->newQuery()->setDebug()->table('tbl_order')->limit(1)->select();
var_dump($result);
}catch (\Throwable $exception) {
var_dump($exception->getMessage());
Expand Down

0 comments on commit 0cbe9dc

Please sign in to comment.