thinkphp5 sql field问题

上图,正常的语句不知道为什么到了第二个field就被改变了

$temp = implode(',',$temp);
    $field = 'comment.*,u.username,moment.moment_content,reply_comment.comment_content as reply_content,';
    $field .= "(select count(reply.id) from ncd_moment_comment as reply where comment.id=reply.reply_comment_id and reply.uid not in ({$temp}) ) as u_reply,";
    $field .= "(select count(reply.id) from ncd_moment_comment as reply where comment.id=reply.reply_comment_id and reply.uid  in ({$temp}) ) as bd_reply";
    $list = $this
        ->alias('comment')
        ->field($field)
        ->join('user u','comment.uid=u.user_id','left')
        ->join('ncd_moment moment','comment.moment_id=moment.id','left')
        ->join('ncd_moment_comment reply_comment','comment.reply_comment_id=reply_comment.id','left')
        ->where($map)
        ->order('comment.comment_release_time desc')
        ->fetchSql()->select();
    echo '<pre>'; var_dump($list);die;
sql语句
string(710) "SELECT `comment`.*,`u`.`username`,`moment`.`moment_content`,reply_comment.comment_content as reply_content,(select count(reply.id) from ncd_moment_comment as reply where comment.id=reply.reply_comment_id and reply.uid not in ('24','25','9917','9921') ) as u_reply,(select count(reply.id) from ncd_moment_comment as reply where comment.id=reply.reply_comment_id and reply.uid  in ('24','9921') ) as bd_reply FROM `ncd_moment_comment` `comment` LEFT JOIN `user` `u` ON `comment`.`uid`=`u`.`user_id` LEFT JOIN `ncd_moment` `moment` ON `comment`.`moment_id`=`moment`.`id` LEFT JOIN `ncd_moment_comment` `reply_comment` ON `comment`.`reply_comment_id`=`reply_comment`.`id` ORDER BY comment.comment_release_time desc"

问题

clipboard.png

clipboard.png

clipboard.png

clipboard.png

阅读 2.3k
1 个回答

已解决,不过用的另一个方法,这里原来的追进去,会发现在db类的field方法被切割,1,2,3,4只剩下头尾,换了另一个写法:上代码

clipboard.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题