dblayer : check if the table name is defined before using it
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2832 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
21
dblayer.php
21
dblayer.php
@@ -559,6 +559,10 @@ class dblayer
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"),
|
||||
500);
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to insert in the table"),
|
||||
500);
|
||||
if ($this->unique === null)
|
||||
throw new Exception (dgettext("domframework",
|
||||
"Unique fields of table are not defined"), 500);
|
||||
@@ -657,6 +661,9 @@ class dblayer
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"),
|
||||
500);
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to read the table"), 500);
|
||||
if ($select !== null && !is_array ($select))
|
||||
throw new Exception (dgettext("domframework",
|
||||
"Select information provided is not an array"),
|
||||
@@ -824,6 +831,10 @@ class dblayer
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"),
|
||||
500);
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to update in the table"),
|
||||
500);
|
||||
if (count ($this->fields) === 0)
|
||||
throw new Exception (dgettext("domframework", "No Field defined"), 500);
|
||||
if ($this->primary === null)
|
||||
@@ -920,6 +931,10 @@ class dblayer
|
||||
if ($this->debug) echo "== Entering delete\n";
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"));
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to delete in the table"),
|
||||
500);
|
||||
$deletekey = $this->hookpredelete ($deletekey);
|
||||
$req = "DELETE FROM $this->sep$this->tableprefix$this->table$this->sep ";
|
||||
$req .= "WHERE $this->primary = :primary";
|
||||
@@ -960,6 +975,9 @@ class dblayer
|
||||
if ($this->debug) echo "== Entering dropTables\n";
|
||||
if ($this->sep === "")
|
||||
throw new Exception (dgettext("domframework", "Database not connected"));
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to drop the table"), 500);
|
||||
$sql = "DROP TABLE $this->sep$this->tableprefix$this->table$this->sep";
|
||||
if ($this->debug)
|
||||
echo "$sql\n";
|
||||
@@ -990,6 +1008,9 @@ class dblayer
|
||||
500);
|
||||
if (count ($this->fields) === 0)
|
||||
throw new Exception (dgettext("domframework", "No Field defined"), 500);
|
||||
if ($this->table === null)
|
||||
throw new \Exception (dgettext("domframework",
|
||||
"No table name defined to create the table"), 500);
|
||||
switch (self::$instance[$this->dsn]->getAttribute(PDO::ATTR_DRIVER_NAME))
|
||||
{
|
||||
case "sqlite":
|
||||
|
||||
Reference in New Issue
Block a user