首页 > 其他 > 详细

yii

时间:2019-08-03 20:15:54      阅读:75      评论:0      收藏:0      [点我收藏+]
  1. 模型
    1. orderby的使用:
      ->orderBy([‘addtime‘=>SORT_DESC, ‘sort‘=>SORT_ASC])->all()
    2. 在使用find()查询的时候, 指定查询字段:
      find()->select(‘id, title, content‘) 指定查询的字段
    3. 块赋值, 使用attributes, 比如 $psychological->attributes = $input; 把数组一次性赋值给attributes 属性, 但是要注意, 要确保模型类中的rules方法, 已经包含了要赋值的字段. 否则attributes 属性接收不到值.
    4. where 作为查询条件单独拿出来的时候, 想使用  <  >  >=  <=  <>  进行范围查询的时候, 要怎么写?
      $where = [
            ‘and‘,
            [‘<‘, ‘minscore‘, $score],
            [‘>‘, ‘maxscore‘, $score],
       ];
      //查询满足minscore<$score并且maxscore>$score 的记录

       

yii

原文:https://www.cnblogs.com/bneglect/p/11295828.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!