| version 1.5, 2017/06/09 15:05:06 |
version 1.6, 2024/11/20 15:48:03 |
|
|
| */ |
*/ |
| public static function isError($value) |
public static function isError($value) |
| { |
{ |
| return is_object($value) && is_a($value, 'DB_Error'); |
return is_object($value) && is_a($value, 'DB_Error'); |
| } |
} |
| |
|
| // }}} |
// }}} |
|
|
| $parsed['dbsyntax'] = $str; |
$parsed['dbsyntax'] = $str; |
| } |
} |
| |
|
| if (!count($dsn)) { |
if (!strlen($dsn)) |
| |
{ |
| return $parsed; |
return $parsed; |
| } |
} |
| |
|
|
|
| * defined, and means that we deal with strings and array in the same |
* defined, and means that we deal with strings and array in the same |
| * manner. */ |
* manner. */ |
| $dsnArray = DB::parseDSN($dsn); |
$dsnArray = DB::parseDSN($dsn); |
| |
|
| if ($hidePassword) { |
if ($hidePassword) { |
| $dsnArray['password'] = 'PASSWORD'; |
$dsnArray['password'] = 'PASSWORD'; |
| } |
} |
|
|
| if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') { |
if (is_string($dsn) && strpos($dsn, 'tcp') === false && $dsnArray['protocol'] == 'tcp') { |
| $dsnArray['protocol'] = false; |
$dsnArray['protocol'] = false; |
| } |
} |
| |
|
| // Now we just have to construct the actual string. This is ugly. |
// Now we just have to construct the actual string. This is ugly. |
| $dsnString = $dsnArray['phptype']; |
$dsnString = $dsnArray['phptype']; |
| if ($dsnArray['dbsyntax']) { |
if ($dsnArray['dbsyntax']) { |
|
|
| $dsnString .= ':'.$dsnArray['port']; |
$dsnString .= ':'.$dsnArray['port']; |
| } |
} |
| $dsnString .= '/'.$dsnArray['database']; |
$dsnString .= '/'.$dsnArray['database']; |
| |
|
| /* Option handling. Unfortunately, parseDSN simply places options into |
/* Option handling. Unfortunately, parseDSN simply places options into |
| * the top-level array, so we'll first get rid of the fields defined by |
* the top-level array, so we'll first get rid of the fields defined by |
| * DB and see what's left. */ |
* DB and see what's left. */ |
|
|
| |
|
| return $dsnString; |
return $dsnString; |
| } |
} |
| |
|
| // }}} |
// }}} |
| } |
} |
| |
|