当前仓库属于关闭状态,部分功能使用受限,详情请查阅 仓库状态说明
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Demo.php 1.99 KB
一键复制 编辑 原始数据 按行查看 历史
sethink 提交于 2019-02-14 09:59 . modify
<?php
/**
* User: sethink
*/
namespace Demo;
include_once "./src/Db.php";
include_once "./src/db/Query.php";
include_once "./src/db/Builder.php";
include_once "./src/MysqlPool.php";
use sethink\swooleOrm\Db;
use sethink\swooleOrm\MysqlPool;
use swoole;
class Demo
{
protected $server;
protected $MysqlPool;
public function __construct()
{
$this->server = new Swoole\Http\Server("0.0.0.0", 9501);
$this->server->set(array(
'worker_num' => 4,
'max_request' => 50000,
'reload_async' => true,
'max_wait_time' => 30,
));
$this->server->on('Start', function ($server) {});
$this->server->on('ManagerStart', function ($server) {});
$this->server->on('WorkerStart', array($this, 'onWorkerStart'));
$this->server->on('WorkerStop', function ($server, $worker_id) {});
$this->server->on('open', function ($server, $request) {});
$this->server->on('Request', array($this, 'onRequest'));
$this->server->start();
}
public function onWorkerStart($server, $worker_id)
{
$config = [
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'sethink',
'password' => 'sethink',
'charset' => 'utf8',
'database' => 'test',
'prefix' => 'sethink_',
'poolMin' => 5,
'clearTime' => 60000,
'clearAll' => 300000,
'setDefer' => true
];
$this->MysqlPool = new MysqlPool($config);
unset($config);
$this->MysqlPool->clearTimer($server);
}
public function onRequest($request, $response)
{
$where['id'] = ['>',5];
$where['id'] = ['<=',10];
$rs = Db::init($this->MysqlPool)
->name('test')
->where(['id'=>['>',5]])
->where(['id'=>['<=',10]])
->fetchSql()
->select();
var_dump($rs);
}
}
new Demo();
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化