mirror of
https://gitlab.com/CodeSolutionsProject/DBWrapper.git
synced 2026-02-14 17:11:33 +01:00
Update dbwrapper.php. Fix Throw
This commit is contained in:
@@ -12,19 +12,19 @@ function dbw_connect($tdb,$server,$database=NULL,$user = NULL,$password=NULL){
|
||||
switch ($tdb){
|
||||
case "mysql":
|
||||
case "mysqli":
|
||||
$return[0] = mysqli_connect($server,$user,$password,$database) or throw new Exception('Database connection error');
|
||||
$return[0] = mysqli_connect($server,$user,$password,$database) or throwExceptionDBConn();
|
||||
$return[1] = "mysqli"; //Return standard mysqli for other funcs.
|
||||
break;
|
||||
case "sqlite":
|
||||
case "sqlite3":
|
||||
$return[0] = new SQLite3($server);
|
||||
if (!$return[0]) throw new Exception('Database connection error');
|
||||
if (!$return[0]) throwExceptionDBConn();
|
||||
$return[1] = "sqlite"; //Return standard SQLite3 for other funcs.
|
||||
break;
|
||||
case "PostgreSQL":
|
||||
case "pg":
|
||||
case "PgSQL":
|
||||
$return[0] = pg_connect("host=$server dbname=$database user=$user password=$password") or throw new Exception('Database connection error. ' . pg_last_error());
|
||||
$return[0] = pg_connect("host=$server dbname=$database user=$user password=$password") or throwExceptionDBConn();
|
||||
$return[1] = "PgSQL"; //Return standard PgSQL for other funcs.
|
||||
break;
|
||||
default:
|
||||
@@ -34,6 +34,10 @@ function dbw_connect($tdb,$server,$database=NULL,$user = NULL,$password=NULL){
|
||||
return $return;
|
||||
}
|
||||
|
||||
function throwExceptionDBConn() {
|
||||
throw new Exception('Database connection error');
|
||||
}
|
||||
|
||||
/** Escapes conflictive chars for inserting into database */
|
||||
function dbw_escape_string($conn,$string){
|
||||
switch ($conn[1]){
|
||||
|
||||
Reference in New Issue
Block a user