国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

think-orm

webman/think-orm 是基于 top-think/think-orm 開發(fā)的數(shù)據(jù)庫(kù)組件,支持連接池,支持協(xié)程和非協(xié)程環(huán)境。

注意
當(dāng)前手冊(cè)為 webman v2 版本,如果您使用的是webman v1版本,請(qǐng)查看 v1版本手冊(cè)

安裝think-orm

composer require -W webman/think-orm

安裝后需要restart重啟(reload無效)

配置文件

根據(jù)實(shí)際情況修改配置文件 config/think-orm.php

文檔地址

https://www.kancloud.cn/manual/think-orm

使用

<?php
namespace app\controller;

use support\Request;
use support\think\Db;

class FooController
{
    public function get(Request $request)
    {
        $user = Db::table('user')->where('uid', '>', 1)->find();
        return json($user);
    }
}

創(chuàng)建模型

think-orm模型繼承support\think\Model,類似如下

<?php
namespace app\model;

use support\think\Model;

class User extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'user';

    /**
     * The primary key associated with the table.
     *
     * @var string
     */
    protected $pk = 'id';

}

你也使用以下命令創(chuàng)建基于think-orm的模型

php webman make:model 表名

提示
此命令需要安裝webman/console,安裝命令為composer require webman/console ^1.2.13

注意
make:model 命令如果檢測(cè)到主項(xiàng)目使用了illuminate/database,會(huì)創(chuàng)建基于illuminate/database的模型文件,而不是think-orm的,這時(shí)可以通過附加一個(gè)參數(shù)tp來強(qiáng)制生成think-orm的模型,命令類似 php webman make:model 表名 tp (如果不生效請(qǐng)升級(jí)webman/console)

編輯于2025-04-18 17:20:05 完善本頁(yè) +發(fā)起討論
贊助商