Sunday, April 16, 2006

A Quickstart to using PEAR with PHP for database driven web applications - Codepoets - David and Katherine Goodwin

intro:This article shows how to use the PEAR DB package for database abstraction and querying.subject:pear, php, database, mysql, postgresqlcontent:What is PEAR::DB?PEAR::DB, provides a uniform, cross platform, cross database method for connecting to databases, when writing PHP applications/scripts.Extensive documentation can be found online hereThis article aims to show briefly, how queries and updates can be performed when using PEAR DB.What's wrong with the traditional PHP method(s)? * Inconsistent API - mysql_connect, pg_connect etc * Different APIs have different methods of connecting to a database * Inconsistent methods for retrieving data and/or performing updates (pg_exec, pg_query, mysql_query etc) * Difficult to port code between databases * Not all APIs support all features (E.g. prepared statements) * Inconsistent error handling (mysql_error(), pg_last_error()) * Secure/safe queries require effort (pg_escape_string(), mysql_real_escape_string(), addslashes(), magic_quotes_gpc())

Read more at www.codepoets.co.uk/doc...

No comments: