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

thinkphp3.2视图模型生成的SQL语句提示1267异常求指点

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

thinkphp 3.2 视图模型 生成的SQL语句提示 1267错误 求指点~
用的TP3.2 视图模型 查询
模型里是这样写的
PicViewModel.class.php
namespace Home\Model;
use Think\Model\ViewModel;
class PicViewModel extends ViewModel{
public $viewFields =array(
'Picture'=> 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

求大神指点下啊
------解决思路----------------------
贴出表结构看看

人气教程排行