sn01615/ssf

此包已被 废弃 且不再维护。未建议替代包。

简单的 swoole 框架

维护者

详细信息

github.com/sn01615/ssf

源代码

问题

安装: 3

依赖者: 0

建议者: 0

安全: 0

星标: 4

关注者: 1

分支: 1

开放问题: 0

类型:项目

v0.0.3 2020-12-21 19:15 UTC

This package is auto-updated.

Last update: 2022-01-21 22:51:42 UTC


README

简单的 swoole 框架

安装

composer create-project sn01615/ssf yourname dev-main

运行

php index.php

Nginx 配置

server {
    ...

    location / {
        try_files $uri /sw_proxy_pass;
    }

    location /sw_proxy_pass {
        proxy_http_version 1.1;
        proxy_set_header Connection "keep-alive";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:9501$request_uri;
    }

    ...
}

数据库:查询构建器

Model 的 mtb 和 tb 属性都是 Illuminate\Database\Eloquent\Builder 实例,不同的是 mtb 使用主库,tb 可能查询从库

查询数据

$result = $this->mtb->where('id', $id)->limit(1)->get()->toArray();

直接运行 SQL(使用 db 属性的 select 等方法)

$result = $this->db->select("select * from user where id = 1 limit 1");

插入数据可以使用 iInsert 方法

$newId = $this->iInsert([
    'name' => 123,
]);

更新数据

$affected = $this->mtb->where('id', 1)->update([
    'name' => '哈哈',
]);

Model 命名说明 TestModel 会映射到 testUserModel 会映射到 userXxCccModel 会映射到 xx_ccc 表,驼峰命名会转成下划线

参考

数据库 Laravel 数据库语法参考 https://laravel.net.cn/docs/5.8/database

模板引擎 Twig 语法参考 https://twig.symfony.com.cn/doc/2.x

使用交流

群号:21890295

论坛:https://www.qingwx.com/category/7