search
HomePHP FrameworkThinkPHPThinkphp 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

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();
    }
}

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),

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!

Statement
This article is reproduced at:CSDN. If there is any infringement, please contact admin@php.cn delete

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.