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

ThinkORM

安裝ThinkORM

composer require -W webman/think-orm:~1.1

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

配置文件

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

文檔地址

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

使用

<?php
namespace app\controller;

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

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

創(chuàng)建模型

ThinkOrm模型繼承think\Model,類似如下

<?php
namespace app\model;

use 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)建基于thinkorm的模型

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的模型文件,而不是thinkorm的,這時(shí)可以通過(guò)附加一個(gè)參數(shù)tp來(lái)強(qiáng)制生成think-orm的模型,命令類似 php webman make:model 表名 tp (如果不生效請(qǐng)升級(jí)webman/console)

編輯于2025-02-27 15:28:12 完善本頁(yè) +發(fā)起討論
贊助商