mysql-thinkphp where is the exception used when using the ID field?

Source: Internet
Author: User
Keywords Thinkphp php mysql
    $n=M("Nav");    $name=$n->where(array('id'=>4))->find();    echo $n->getLastSql();    

The result of the output is:

SELECT * FROM `aa_nav` LIMIT 1

Why is the Where condition gone?
When I do not use an array in the Where condition, and the string is not a problem.

Reply content:

    $n=M("Nav");    $name=$n->where(array('id'=>4))->find();    echo $n->getLastSql();    

The result of the output is:

SELECT * FROM `aa_nav` LIMIT 1

Why is the Where condition gone?
When I do not use an array in the Where condition, and the string is not a problem.

Thinkphp 3.2.3 says everything is OK, you can use array

Not sure if it is a version issue, 3.x version will not have this problem.

['id']=4

It should be ok

Confirm that there is an ID in this field?

The problem is solved, explain the specific situation:
1. The table built with the Mysql-front tool, by default, has a self-increment column named "id" instead of "id";
2. When using the thinkphp where condition, if it is in the form of a string, it should be case-insensitive, so I put the ID as an ID is also possible, but with the formation of the array is case-sensitive, the case of the wrong size will be a problem.

In addition, thank you for your reply.

  • Related Article

    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.