当前位置:Gxlcms > PHP教程 > thinkphp3.2视图模型生成的SQL语句提示1267错误求指点~

thinkphp3.2视图模型生成的SQL语句提示1267错误求指点~

时间:2021-07-01 10:21:17 帮助过:6人阅读

用的TP3.2 视图模型 查询
模型里是这样写的
PicViewModel.class.php
 array('picTitle','picToken','picCategroy','picAuthor','picPostTime','_as'=>'Picture'),        'PictureAttachment' =>array('pictureid','pictureurl','creattime','_on'=>'Picture.picToken = PictureAttachment.pictureid','_as'=>'PictureAttachment'),    );}

控制器这样写
  public function  Pic(){         $PicModel =D('PicView');            $s1= $PicModel->field('picTitle,picCategroy,picAuthor,picPostTime,pictureurl')->order('picPostTime desc')->select();        dump($PicModel->getLastSql());        dump($s1);    }

生成的SQL 语句是这样的
SELECT Picture.picTitle AS picTitle,Picture.picCategroy AS picCategroy,Picture.picAuthor AS picAuthor,Picture.picPostTime AS picPostTime,PictureAttachment.pictureurl AS pictureurl FROM xxx_picture Picture  JOIN xxx_picture_attachment PictureAttachment ON Picture.picToken = PictureAttachment.pictureid ORDER BY Picture.picPostTime desc

在phpmyadmin里运行出现
MySQL 返回: 文档

#1267 - Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation '='
这个应该是排序规则不同 然后我在phpmyadmin里直接修改表的
改成一样是utf8_general_ci,了 还是报错

网上查了是这样执行
alert xxx_picture_attachment CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci
ALTER xxx_picture_attachment DEFAULT CHARACTER SET utf8_general_ci
貌似也不行额
报错
MySQL 返回: 文档

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'alert xxx_picture_attachment CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_' at line 1

求大神指点下啊


回复讨论(解决方案)

贴出表结构看看

贴出表结构看看



谢谢提醒 原来是字段的排序问题 谢谢 了~

人气教程排行