代码拉取完成,页面将自动刷新
<?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();
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。