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
求大神指點下啊
------解決思路----------------------
貼出表結構看看