virtual techdays - PowerPoint PPT Presentation

charde-kaufman
slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
virtual techdays PowerPoint Presentation
Download Presentation
virtual techdays

play fullscreen
1 / 19
Download Presentation
virtual techdays
81 Views
Download Presentation

virtual techdays

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. INDIA │ 18-20 august2010 virtual techdays Connect to SQL from PHP Praveen Srivatsa│ Director, AsthraSoft Consulting Microsoft Regional Director, Bangalore MVP, ASP.NET

  2. 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. Why use PDO? • Portability • Performance • Power • Easy • Runtime Extensible

  4. What databases does it support? • Sybase • Firebird / Interbase • DB2 / INFORMIX (IBM) • MySQL • OCI (Oracle Call Interface) • ODBC • PostgreSQL • SQLite Now with SQL Server Driver for PHP Support as well

  5. DSNs • In general drivername:<driver-specific-stuff> • mysql:host=name;dbname=dbname • odbc:odbc_dsn • oci:dbname=dbname;charset=charset • sqlite:/path/to/db/file • sqlite::memory:

  6. Connect to the database

  7. Persistent PDO Connection • Connection stays alive between requests $dbh = new PDO($dsn, $user, $pass, array( PDO_ATTR_PERSISTENT => true ) );

  8. PDO Query (INSERT)

  9. PDO Query (UPDATE)

  10. PDO Query (SELECT)

  11. Error Handling (1)

  12. Error Handling (2)

  13. Error Handling (3)

  14. Error Handling (4)

  15. Prepared statements

  16. Transactions

  17. Get Last Insert Id

  18. Benchmark

  19. THANKS│18-20 august2010 virtual techdays praveens@asthra.net│ connect.asthrasoft.com/asthratimes