mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-09-21 06:20:17 +00:00
Fix the SetConnection() method.
This commit is contained in:
parent
1467801345
commit
356fbb03ea
@ -238,15 +238,15 @@ class AwlQuery
|
|||||||
* @param resource $new_connection The database connection to use.
|
* @param resource $new_connection The database connection to use.
|
||||||
*/
|
*/
|
||||||
function SetConnection( $new_connection, $options = null ) {
|
function SetConnection( $new_connection, $options = null ) {
|
||||||
if ( is_string($new_connection) ) {
|
if ( is_string($new_connection) || is_array($new_connection) ) {
|
||||||
$dbuser = null;
|
$dbuser = null;
|
||||||
$dbpass = null;
|
$dbpass = null;
|
||||||
if ( is_array($v) ) {
|
if ( is_array($new_connection) ) {
|
||||||
$dsn = $v['dsn'];
|
$dsn = $new_connection['dsn'];
|
||||||
if ( isset($v['dbuser']) ) $dbuser = $v['dbuser'];
|
if ( isset($new_connection['dbuser']) ) $dbuser = $new_connection['dbuser'];
|
||||||
if ( isset($v['dbpass']) ) $dbpass = $v['dbpass'];
|
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];
|
$dsn = $matches[2];
|
||||||
if ( isset($matches[1]) && $matches[1] != '' ) {
|
if ( isset($matches[1]) && $matches[1] != '' ) {
|
||||||
$dsn = $matches[1] . $dsn;
|
$dsn = $matches[1] . $dsn;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user