Download presentation
Presentation is loading. Please wait.
Published byValentine Thornton Modified over 9 years ago
1
PHP Workshop ‹#› PHP Data Object (PDO)
2
PHP Workshop ‹#› What is PDO? PDO is a PHP extension to formalise PHP's database connections by creating a uniform interface. This allows developers to create code which is portable across many databases and platforms. PDO is not just another abstraction layer like PEAR DB or ADOdb.
3
PHP Workshop ‹#› Why use PDO? Portability Performance Power Easy Runtime Extensible
4
PHP Workshop ‹#› What databases does it support? Microsoft SQL Server / Sybase Firebird / Interbase DB2 / INFORMIX (IBM) MySQL OCI (Oracle Call Interface) ODBC PostgreSQL SQLite
5
PHP Workshop ‹#› DSNs In general drivername: mysql:host=name;dbname=dbname odbc:odbc_dsn oci:dbname=dbname;charset=charset sqlite:/path/to/db/file sqlite::memory:
6
PHP Workshop ‹#› Connect to MySQL
7
PHP Workshop ‹#› Connect to SQLite (file)
8
PHP Workshop ‹#› Connect to SQLite (memory)
9
PHP Workshop ‹#› Connect to Oracle
10
PHP Workshop ‹#› Connect to ODBC
11
PHP Workshop ‹#› Close a Database Connection
12
PHP Workshop ‹#› Persistent PDO Connection Connection stays alive between requests $dbh = new PDO($dsn, $user, $pass, array( PDO_ATTR_PERSISTENT => true ) );
13
PHP Workshop ‹#› PDO Query (INSERT)
14
PHP Workshop ‹#› PDO Query (UPDATE)
15
PHP Workshop ‹#› PDO Query (SELECT)
16
PHP Workshop ‹#› Error Handling (1)
17
PHP Workshop ‹#› Error Handling (2)
18
PHP Workshop ‹#› Error Handling (3)
19
PHP Workshop ‹#› Error Handling (4)
20
PHP Workshop ‹#› Prepared statements
21
PHP Workshop ‹#› Transactions
22
PHP Workshop ‹#› Get Last Insert Id
23
PHP Workshop ‹#› Benchmark MySQL SELECT Benchmark Results, 1000 Requests LibraryConcurrencyTotal TimeRequests/Sec.Speedup ADOdb120.90/sec47.84- PDO10.73/sec1358.62+2840% ADOdb5010.78/sec99.23- PDO500.54/sec1850.90+1865% ADOdb10010.44/sec95.78- PDO1000.53/sec1869.33+1952%
24
PHP Workshop ‹#› Questions
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.