Home > Backend Development > PHP Tutorial > php framework - thinkPHP is written in DB_DSN and it is pdo mode. If it is not written, it is mysql mode?

php framework - thinkPHP is written in DB_DSN and it is pdo mode. If it is not written, it is mysql mode?

WBOY
Release: 2016-07-06 13:53:39
Original
1643 people have browsed it

<code>'DB_TYPE'=>'mysql', //数据库类型
'DB_USER'=>'root', //用户名
'DB_PWD'=>'123456', //密码
'DB_PREFIX'=>'think_', //数据库表前缀
'DB_DSN'=>'mysql:host=localhost;dbname=thinkphp;charset=UTF8',  //★★注意这里. </code>
Copy after login
Copy after login

If you write 'DB_DSN' like this, it will automatically use PDO to connect. If you don't write 'DB_DSN', it will be mysql connection?

Or do you still use Pdo to connect regardless of writing or not?

How to connect using other parameter settings?

Reply content:

<code>'DB_TYPE'=>'mysql', //数据库类型
'DB_USER'=>'root', //用户名
'DB_PWD'=>'123456', //密码
'DB_PREFIX'=>'think_', //数据库表前缀
'DB_DSN'=>'mysql:host=localhost;dbname=thinkphp;charset=UTF8',  //★★注意这里. </code>
Copy after login
Copy after login

If you write 'DB_DSN' like this, it will automatically use PDO to connect. If you don't write 'DB_DSN', it will be mysql connection?

Or do you still use Pdo to connect regardless of writing or not?

How to connect using other parameter settings?

For versions below TP3.2.3, if DB_TYPE uses the PDO type, the database type is determined by the DB_DSN configuration. Version 3.2.3 or above, DB_DSN does not require setting, it is automatically set by the system. If it is version 3.2.3, since the PDO method is all used, DB_TYPE needs to be configured as the actual database type. It is no longer supported to be set to PDO, and there is no distinction between mysql and mysqli. Reference document I hope it will be helpful to you

Related labels:
source:php.cn
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