Add Exception code in dblayer
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1701 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
18
dblayer.php
18
dblayer.php
@@ -64,7 +64,7 @@ class dblayer extends PDO
|
|||||||
public function databasename ()
|
public function databasename ()
|
||||||
{
|
{
|
||||||
if ($this->db === null)
|
if ($this->db === null)
|
||||||
throw new Exception (dgettext("domframework", "Database not connected"));
|
throw new Exception (dgettext("domframework", "Database not connected"), 500);
|
||||||
$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)
|
||||||
@@ -81,7 +81,7 @@ class dblayer extends PDO
|
|||||||
public function listTables ()
|
public function listTables ()
|
||||||
{
|
{
|
||||||
if ($this->db === null)
|
if ($this->db === null)
|
||||||
throw new Exception (dgettext("domframework", "Database not connected"));
|
throw new Exception (dgettext("domframework", "Database not connected"), 500);
|
||||||
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
|
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
|
||||||
{
|
{
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
@@ -114,7 +114,7 @@ class dblayer extends PDO
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Exception (dgettext("domframework",
|
throw new Exception (dgettext("domframework",
|
||||||
"Unknown database driver in listTables"));
|
"Unknown database driver in listTables"), 500);
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
@@ -151,7 +151,7 @@ class dblayer extends PDO
|
|||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
throw new Exception ("PDO error : ".$e->getMessage());
|
throw new Exception ("PDO error : ".$e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force specifics initialisations
|
// Force specifics initialisations
|
||||||
@@ -735,7 +735,7 @@ class dblayer extends PDO
|
|||||||
public function createTable ()
|
public function createTable ()
|
||||||
{
|
{
|
||||||
if ($this->db === null)
|
if ($this->db === null)
|
||||||
throw new Exception (_("Database not connected"));
|
throw new Exception (_("Database not connected"), 500);
|
||||||
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
|
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
|
||||||
{
|
{
|
||||||
case "sqlite":
|
case "sqlite":
|
||||||
@@ -761,7 +761,7 @@ class dblayer extends PDO
|
|||||||
break;
|
break;
|
||||||
case "varchar":
|
case "varchar":
|
||||||
if (!isset ($params[1]))
|
if (!isset ($params[1]))
|
||||||
throw new Exception (_("No Size provided for varchar field"));
|
throw new Exception (_("No Size provided for varchar field"), 500);
|
||||||
$sql .= "VARCHAR(".$params[1].")";
|
$sql .= "VARCHAR(".$params[1].")";
|
||||||
$params = array_slice ($params, 2);
|
$params = array_slice ($params, 2);
|
||||||
break;
|
break;
|
||||||
@@ -803,7 +803,7 @@ class dblayer extends PDO
|
|||||||
{
|
{
|
||||||
if (!is_array ($this->unique))
|
if (!is_array ($this->unique))
|
||||||
throw new Exception (
|
throw new Exception (
|
||||||
_("The Unique field definition is not an array"));
|
_("The Unique field definition is not an array"), 500);
|
||||||
foreach ($this->unique as $u)
|
foreach ($this->unique as $u)
|
||||||
{
|
{
|
||||||
$sql .= ",\n UNIQUE (`";
|
$sql .= ",\n UNIQUE (`";
|
||||||
@@ -839,7 +839,7 @@ class dblayer extends PDO
|
|||||||
$sql .= "`$field` ";
|
$sql .= "`$field` ";
|
||||||
// Type of field : in $params[0]
|
// Type of field : in $params[0]
|
||||||
if (!isset ($params[0]))
|
if (!isset ($params[0]))
|
||||||
throw new Exception (_("No database type defined for field"));
|
throw new Exception (_("No database type defined for field"), 500);
|
||||||
switch ($params[0])
|
switch ($params[0])
|
||||||
{
|
{
|
||||||
case "integer":
|
case "integer":
|
||||||
@@ -848,7 +848,7 @@ class dblayer extends PDO
|
|||||||
break;
|
break;
|
||||||
case "varchar":
|
case "varchar":
|
||||||
if (!isset ($params[1]))
|
if (!isset ($params[1]))
|
||||||
throw new Exception (_("No Size provided for varchar field"));
|
throw new Exception (_("No Size provided for varchar field"), 500);
|
||||||
$sql .= "VARCHAR(".$params[1].")";
|
$sql .= "VARCHAR(".$params[1].")";
|
||||||
$params = array_slice ($params, 2);
|
$params = array_slice ($params, 2);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user