Connecting to the database in the Zend Developer Cloud is quite easy. You just need the container name, database name, username and password. But what if you changed containers or your password?
If you want to make your application able to be easily moved between containers (and you should) here is a stupid easy way to do it. Use get_cfg_var().
$dsn = sprintf( 'mysql:dbname=%s;host=%s', get_cfg_var('zend_developer_cloud.db.name'), get_cfg_var('zend_developer_cloud.db.host') ); $db = new PDO( $dsn, get_cfg_var('zend_developer_cloud.db.username'), get_cfg_var('zend_developer_cloud.db.password') );