The SQL statement generated by the thinkphp3.2 View model prompts 1267 error ~ -Php Tutorial

Source: Internet
Author: User
The SQL statement generated by the thinkphp3.2 View model prompts 1267 error ~ Query using the TP3.2 View model
This is written in the model.
PicViewModel. class. php
  array('picTitle','picToken','picCategroy','picAuthor','picPostTime','_as'=>'Picture'),        'PictureAttachment' =>array('pictureid','pictureurl','creattime','_on'=>'Picture.picToken = PictureAttachment.pictureid','_as'=>'PictureAttachment'),    );}

Write controller like this
  public function  Pic(){         $PicModel =D('PicView');            $s1= $PicModel->field('picTitle,picCategroy,picAuthor,picPostTime,pictureurl')->order('picPostTime desc')->select();        dump($PicModel->getLastSql());        dump($s1);    }

The generated SQL statement is as follows:
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

Running in phpmyadmin
MySQL return: document

#1267-Illegal mix of collations (utf8_general_ci, IMPLICIT) and (utf8_unicode_ci, IMPLICIT) for operation '='
This should be because the sorting rules are different. then I directly modify the table in phpmyadmin.
It is utf8_general_ci, and an error is returned.

I checked it online.
Alert xxx_picture_attachment convert to character set utf8 COLLATE utf8_general_ci
ALTER xxx_picture_attachment default character set utf8_general_ci
It does not seem to work either.
Error
MySQL return: document

#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

Please give me some advice.


Reply to discussion (solution)

Paste the table structure

Paste the table structure



Thank you for reminding me that it was a field sorting problem. thank you ~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.