PHP knowledge point note error: PDOException cocould not find driver.
Yes, it indicates that PDO has not installed the corresponding database extension, for example, PDO_mysql has not been installed.
Http://pecl.php.net/package/PDO_MYSQL
Download source code
Phpize
./Configure -- with-php-config =/usr/local/php/bin/php-config
./Make
./Make install
PhpExcel needs to use xmlreader and xmlwriter extensions of php.
If you are using yum to install php
Directly use yum install php-xml for installation.
Define of php cannot be defined repeatedly
For example:
[yejianfeng@xen193v ~/handcode]$ php test.php PHP Notice: Constant TEST already defined in /home/yejianfeng/handcode/test.php on line 4Notice: Constant TEST already defined in /home/yejianfeng/handcode/test.php on line 411
How does PHP obtain all local variables?$ LocalVariables = compact (array_keys (get_defined_vars ()));
Install the php module in this way.PHP_PDO_SHARED = 1 pecl install pdo_mysql
Mysql character encodingMysql uses latin1 as the default client character encoding.
Mysql character encoding includes the following types:
Mysql> show variables like "character_set _ % ";
+ -------------------------- + ---------------------------- +
| Variable_name | Value |
+ -------------------------- + ---------------------------- +
| Character_set_client | utf8 |
| Character_set_connection | utf8 |
| Character_set_database | latin1 |
| Character_set_filesystem | binary |
| Character_set_results | utf8 |
| Character_set_server | latin1 |
| Character_set_system | utf8 |
| Character_sets_dir |/usr/share/mysql/charsets/|
+ -------------------------- + ---------------------------- +
The information input path is
Client-connection-server
The information output path is
Server-connection-result
The input set names utf8 is the character encoding for the temporary setting of client and connection.
How to initialize mysql character encoding in PHP?There are two ways to initialize the settings:
1
$pdo = new PDO("mysql:host={$config['host']};dbname={$config['dbname']};port={$config['port']}", $config['user'], $config['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); 2
$pdo = new PDO("mysql:host={$config['host']};dbname={$config['dbname']};port={$config['port']}", $config['user'], $config['password']); $pdo->exec('set names utf8');PDO extension of PHP
If you want to use PDO in php, you need to install the extension in addition to PDO and drivers of various databases. The PDO extension defines a series of interfaces, but you cannot use the PDO extension to directly operate the database, need to install and develop the PDO driver extension
Description of PDO extensions: http://www.php.net/manual/en/intro.pdo.php
The PDO extension can only be used on top of PHP 5.0 (the php OO attribute is used)
Extensions for different databases include:
Why can't PDO prepare output the final SQL statement?The use of PDO has always been depressing, that is, when using prepare, you want to output the last executed SQL statement as a log. there is no way to do this...
Later I thought about it. if prepare is a mysql statement, the PDO prepare and execute actually send several requests to mysql, including prepare, set, and execute.
mysql> PREPARE stmt1 FROM 'SELECT SQRT(POW(?,2) + POW(?,2)) AS hypotenuse';mysql> SET @a = 3;mysql> SET @b = 4;mysql> EXECUTE stmt1 USING @a, @b;+------------+| hypotenuse |+------------+| 5 |+------------+mysql> DEALLOCATE PREPARE stmt1;
Therefore, if you want to output logs, you only need to spell SQL by yourself...