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('Praise'); $a=$result->select(); var_dump($a); die; $this->display(); } }
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
'DB_PARAMS' => array(\PDO::ATTR_CASE => \PDO::CASE_NATURAL),
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!