欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

thinkphp 3.2 视图模型 生成的SQL语句提示 1267异常 求指点

程序员文章站 2022-03-04 09:43:14
...
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

求大神指点下啊
------解决思路----------------------
贴出表结构看看
thinkphp 3.2 视图模型 生成的SQL语句提示 1267异常 求指点

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频