Fix the SetConnection() method.

This commit is contained in:
Andrew McMillan 2010-04-26 19:46:07 +12:00
parent 1467801345
commit 356fbb03ea

View File

@ -238,15 +238,15 @@ class AwlQuery
* @param resource $new_connection The database connection to use.
*/
function SetConnection( $new_connection, $options = null ) {
if ( is_string($new_connection) ) {
if ( is_string($new_connection) || is_array($new_connection) ) {
$dbuser = null;
$dbpass = null;
if ( is_array($v) ) {
$dsn = $v['dsn'];
if ( isset($v['dbuser']) ) $dbuser = $v['dbuser'];
if ( isset($v['dbpass']) ) $dbpass = $v['dbpass'];
if ( is_array($new_connection) ) {
$dsn = $new_connection['dsn'];
if ( isset($new_connection['dbuser']) ) $dbuser = $new_connection['dbuser'];
if ( isset($new_connection['dbpass']) ) $dbpass = $new_connection['dbpass'];
}
elseif ( preg_match( '/^(\S+:)?(.*)( user=(\S+))?( password=(\S+))?$/', $v, $matches ) ) {
elseif ( preg_match( '/^(\S+:)?(.*)( user=(\S+))?( password=(\S+))?$/', $new_connection, $matches ) ) {
$dsn = $matches[2];
if ( isset($matches[1]) && $matches[1] != '' ) {
$dsn = $matches[1] . $dsn;