Blogger Information
Blog 20
fans 0
comment 0
visits 8219
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
model创建、model查询数据库、model 的配置、model 获取器、修改器
P粉191340380
Original
541 people have browsed it

联表查询

  1. $ret = Db::table('mhh_user u')->join('mhh_order o','u.uid = o.uid')->select();
  2. print_r($ret);

model配置

  1. use app\model\User;

model查询数据库

  1. $ret = User::where('uid',10)->find();
  2. print_r($set['nickname']);

model获取器

  1. // 获取器格式:get + 字段 + Attr 创建一个方法名
  2. public function getStatusAttr($v){
  3. $arr = [
  4. 0=>'禁用',
  5. 1=>'启用',
  6. 2=>'待审核'
  7. ];
  8. return $arr[$v];
  9. return ['0'=>'禁用','1'=>'启用',];
  10. }

model修改器

  1. // 修改器格式:set + 字段 + Attr 创建一个方法名
  2. public function setPasswordAttr($v,$all){
  3. return md($v);
  4. }
  5. `
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