Blogger Information
Blog 20
fans 0
comment 0
visits 8104
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
thinkPHP Model搜索器、门面类、开启调试、助手函数、多应用
P粉191340380
Original
541 people have browsed it

搜索器

  1. public function sele(){
  2. $data = User::withSearch(
  3. ['name'],
  4. [
  5. 'name'=>'编',
  6. 'add_time'=>time()
  7. ]
  8. )->select();
  9. return $data;
  10. }
  11. // 搜索器 search + 字段名 + Attr
  12. public function searchNameAttr($query, $value){
  13. $query->where('name','like','%'. $value.'%');
  14. }

门面类

  1. namespace app\index\controller;
  2. use app\BaseController;
  3. // 引入Db门面类
  4. use think\facade\Db;
  5. // 引入Request;
  6. use think\facade\Request;
  7. class Index extends BaseController{
  8. public function index(){
  9. $user = Db::table('mhh_user')->select();
  10. dump($user);
  11. }
  12. }

开启调试

  1. // 如果部署到服务器的话,你可以通过下面方式安装
  2. composer install --no-dev
  3. // 设置开启调试模式
  4. APP_DEBUG = true

助手函数

  1. // 获取get和post的传值
  2. input('get.');
  3. input('post.');

多应用

  1. // 如果需要使用多应用需要先进行安装多应用功能
  2. composer require topthink/think-multi-app
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!