About errors in the Thinkphp framework model application process undefined class constant Mysql_attr_init_command

Source: Internet
Author: User

Today, when using the thinkphp framework to make a Web site, it is an unexpected occurrence when calling the model Fatal error: uncaught exception ' pdoexception ' with message ' sqlstate[ 42S02] Error,

The following is my Baidu results, most of the problem can be divided into the following two categories:

1.

Under Windows iis7.5+php5.4.11 (FastCGI)

Missing PDO, editing php.ini

Uncomment:

Extension=php_pdo_mysql.dll

Restart IIS

The PHP Data Object (PDO) extension defines a lightweight, consistent interface to access the database. Each driver that implements the PDO interface exhibits database-related features like a generic extension function. You cannot perform any database functions with the PDO function itself. You must use a database-related driver to access the database server.
PDO provides a data access abstraction layer, meaning that you can publish queries and retrieve data using the same functions without knowing what database you are using.

2. Modify the code:

This situation (Undefined class constant ' Mysql_attr_init_command ') is a PHP5.3.0 bug, see http://bugs.php.net/bug.php?id=47224
There are two ways to solve the problem, one is to change the code
$pdb = new PDO ("Mysql:host=localhost;dbname=test", ' root ');
$pdb->exec ("SET NAMES UTF8");
The second is to upgrade your PHP to a higher version

To the above users of the answer I myself tinker for a long time also did not solve, finally in their own research found the solution is actually very simple:

The TP operation model is similar to the hibernait Operation data table in JSP, the model name you want to manipulate must correspond to your table name, which is a way

Another way is: protected $trueTableName = "; invoke the statement to manipulate the real data table

About errors in the Thinkphp framework model application process undefined class constant Mysql_attr_init_command

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.