Home > PHP Framework > ThinkPHP > Thinkphp cannot recognize the case of data table names and solve the problem

Thinkphp cannot recognize the case of data table names and solve the problem

Release: 2020-05-02 09:00:37
forward
3202 people have browsed it

Thinkphp cannot recognize the case of data table names and solve the problem

When I first came into contact with thinkphp some time ago, the problem with the case of database table names occurred when I first used it. By default, thinkphp changes all uppercase letters to lowercase letters and adds a _ symbol in the middle.

Later I modified the source code and it was able to run normally, but it took too long and I forgot how I changed it. Here we only talk about solutions, without specific implementation steps.

Error code:

<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
           $result=M(&#39;Praise&#39;);
        $a=$result->select();
        var_dump($a);
        die;
        $this->display();
    }
}
Copy after login

The error is like this

1146:Table 'MovierDC.praise' doesn't exist [SQL statement]: SHOW COLUMNS FROM praise

I found an explanation on the Internet to modify the configuration items

&#39;DB_PARAMS&#39; => array(\PDO::ATTR_CASE => \PDO::CASE_NATURAL),
Copy after login

Later I found out that some people just copied and pasted to answer other people's questions and made mistakes. This is a configuration table field that is not case sensitive.

I can't find the configuration item about the configuration table name. So I started directly from the source code (focus on the error report), mainly two functions, One is a function that converts all letters into lowercase letters, and the other is a function that splits and reorganizes. Remove functions converted to lowercase, and functions that are split and reorganized are also removed. Finally it works.

Recommended tutorial: "TP5"

The above is the detailed content of Thinkphp cannot recognize the case of data table names and solve the problem. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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