to be The PHP Access database defines a lightweight, consistent interface. Each database driver that implements the PDO interface can expose the characteristics of a specific database as a standard extension feature. Note that using PDO to extend itself does not enable any database functionality; You must use the PDO driver for a specific database to access the database service.
PDO provides a data access abstraction layer, which means that the same functions (methods) can be used to query and fetch data regardless of the database used. PDO does not provide a database abstraction layer; it does not rewrite SQL, nor does it emulate missing attributes. If necessary, use a mature abstraction layer.
the connection string for the database, including the database type, the connected library name, the connected address, the connected port number, the connected character set
For example :
$dsn ='mysql:dbname=pg39;host=127.0.0.1;port=13306;charset=utf8'
users accessing the data
$user ='root';
password to access the database
$password =";
Creating a PDO object that connects the operations database MySQL
$DBH =new PDO ($dsn, $user, $password);
define SQL statements sent to database server side execution and return results
$pt = $dbh->query (' select*from student ', pdo::fetch_num);
action and Extract return value results
$arr =array ();
foreach ($pt as $val) {
Array_push ($arr, $val);
}
Var_dump ($arr);
close the data object after the Operation
$DBH =null;
all the DML Operations Use the exec function, the return value is the number of rows affected, the integer value
Parse_ini_file: parsing a configuration file
For example :
if (file_exists (' db ')) {
$ini _array= @parse_ini_file ("db");
Print_r ($ini _array);
}
PHP Data Objects (PDO)