企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
### 创建模型 php bin/hyperf.php gen:model Users ### 配置数据库连接 .evn配置链接 APP_NAME=skeleton DB_DRIVER=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=swoole DB_USERNAME=swoole DB_PASSWORD=swoole DB_CHARSET=utf8mb4 DB_COLLATION=utf8mb4_unicode_ci DB_PREFIX= ### curd的练习操作 #### 查询单条 $users = User::query()->first(); #### 查询全部 $users = User::all(); #### 分页查询 $users = User::query()->paginate(2); #### 添加 $user = new User(); $user->username = 'abc' . mt_rand(1000, 9999); $user->create_at = time(); $user->update_at = time(); $res = $user->save(); #### 修改 $users = User::query()->find(1); $user->username = 'abc' . mt_rand(1000, 9999); #### 删除 $id = $this->request->input('id'); User::destroy($id);