thinkphp 3.2 视图模型 生成的SQL语句提示 1267错误 求指点~

WBOY
Release: 2016-06-23 13:44:29
Original
1253 people have browsed it

用的TP3.2 视图模型 查询 
模型里是这样写的 
PicViewModel.class.php

<?phpnamespace 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'),    );}
Copy after login

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

生成的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
Copy after login

在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 

求大神指点下啊


回复讨论(解决方案)

贴出表结构看看

贴出表结构看看



谢谢提醒 原来是字段的排序问题 谢谢 了~
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template