dblayeroo: the connect process need now the database name and generate an Exception if not provided in the DSN
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@3725 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -115,10 +115,11 @@ class dblayeroo
|
|||||||
$this->DBException ("PDO error : ".$e->getMessage ());
|
$this->DBException ("PDO error : ".$e->getMessage ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force ForeignKeys support (disabled by default)
|
// Force ForeignKeys support (disabled by default)
|
||||||
self::$instance[$this->dsn]->exec ("PRAGMA foreign_keys = ON");
|
self::$instance[$this->dsn]->exec ("PRAGMA foreign_keys = ON");
|
||||||
$this->sep = "`";
|
$this->sep = "`";
|
||||||
|
if ($this->databasename () === null)
|
||||||
|
$this->DBException ("No Database provided in DSN");
|
||||||
break;
|
break;
|
||||||
case "mysql":
|
case "mysql":
|
||||||
if (! array_key_exists ($this->dsn, self::$instance))
|
if (! array_key_exists ($this->dsn, self::$instance))
|
||||||
@@ -141,6 +142,8 @@ class dblayeroo
|
|||||||
// Set the coding to UTF8
|
// Set the coding to UTF8
|
||||||
self::$instance[$this->dsn]->exec ("SET CHARACTER SET utf8");
|
self::$instance[$this->dsn]->exec ("SET CHARACTER SET utf8");
|
||||||
$this->sep = "`";
|
$this->sep = "`";
|
||||||
|
if ($this->databasename () === null)
|
||||||
|
$this->DBException ("No Database provided in DSN");
|
||||||
break;
|
break;
|
||||||
case "pgsql":
|
case "pgsql":
|
||||||
if (! array_key_exists ($this->dsn, self::$instance))
|
if (! array_key_exists ($this->dsn, self::$instance))
|
||||||
@@ -162,6 +165,8 @@ class dblayeroo
|
|||||||
// Set the coding to UTF8
|
// Set the coding to UTF8
|
||||||
self::$instance[$this->dsn]->exec ("SET NAMES 'utf8'");
|
self::$instance[$this->dsn]->exec ("SET NAMES 'utf8'");
|
||||||
$this->sep = "\"";
|
$this->sep = "\"";
|
||||||
|
if ($this->databasename () === null)
|
||||||
|
$this->DBException ("No Database provided in DSN");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->DBException (dgettext ("domframework",
|
$this->DBException (dgettext ("domframework",
|
||||||
@@ -216,6 +221,13 @@ class dblayeroo
|
|||||||
{
|
{
|
||||||
if ($this->sep === "")
|
if ($this->sep === "")
|
||||||
$this->DBException (dgettext ("domframework", "Database not connected"));
|
$this->DBException (dgettext ("domframework", "Database not connected"));
|
||||||
|
if ($this->driver === "sqlite")
|
||||||
|
{
|
||||||
|
$dbFile = substr (strstr ($this->dsn, ":"), 1);
|
||||||
|
if (trim ($dbFile) !== "")
|
||||||
|
return $dbFile;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
$vals = explode (";", substr (strstr ($this->dsn, ":"), 1));
|
$vals = explode (";", substr (strstr ($this->dsn, ":"), 1));
|
||||||
$dsnExplode = array ();
|
$dsnExplode = array ();
|
||||||
foreach ($vals as $val)
|
foreach ($vals as $val)
|
||||||
|
|||||||
Reference in New Issue
Block a user