lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
PHP/MySQL: updating rows with ADOdb Lite
Two ways to create a ADODB Lite object. The second, using DSN (Data Source Name) allows you to set a flag that will count updated rows even when they aren't changed. (This is significant if you are a defensive programmer like me.)

Simple Instantiation
$DBSingle =& ADONewConnection($db_type);
$DBSingle->db_name = $db_name;
if ( !$DBSingle->Connect($db_server, $db_user, $db_pass, $db_name) ) trigger_error('unable to connect to database [' . $db_name . ']', E_USER_WARNING);


DSN Instantiation
$_pw = urlencode($db_pass);
$_flags = 2;
$_dsn = "mysql://$db_user:$_pw@$db_server/$db_name?clientflags=$_flags";
if ( !$DBSingle =& ADONewConnection($_dsn) ) trigger_error('unable to connect to database [' . $db_name . ']', E_USER_WARNING);


References:
ADO Documentation: DSN Support

keywords: php, mysql, adodb, adodb_lite, update, count, dsn