1 Star 0 Fork 9

恢恢娱乐 / swoole-orm

forked from sethink / swoole-orm
关闭
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
Demo.php 1.79 KB
一键复制 编辑 Web IDE 原始数据 按行查看 历史
sethink 提交于 2018-12-19 15:05 . 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' => 'root',
'password' => 'root',
'charset' => 'utf8',
'database' => 'test',
'prefix' => 'sethink_',
'poolMin' => 5,
'clearTime' => 60000,
'clearAll' => 300000,
];
$this->MysqlPool = new MysqlPool($config);
unset($config);
$this->MysqlPool->clearTimer($server);
}
public function onRequest($request, $response)
{
$rs = Db::init($this->MysqlPool)
->name('test')
->select();
var_dump($rs);
}
}
new Demo();
PHP
1
https://gitee.com/hhyl/swoole-orm.git
git@gitee.com:hhyl/swoole-orm.git
hhyl
swoole-orm
swoole-orm
master

搜索帮助