dblayer/authorizationdb : tableprefix is updated
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1595 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
27
dblayer.php
27
dblayer.php
@@ -35,9 +35,9 @@ class dblayer extends PDO
|
||||
{
|
||||
/** The table name to use */
|
||||
public $table = null;
|
||||
/** The prefix text to prepend to table name (Should finish by _)
|
||||
/** The tableprefix text to prepend to table name (Should finish by _)
|
||||
Just allow chars ! */
|
||||
public $prefix = "";
|
||||
public $tableprefix = "";
|
||||
/** The fields with the definition of type, and special parameters */
|
||||
public $fields = array ();
|
||||
/** The primary field */
|
||||
@@ -166,7 +166,8 @@ class dblayer extends PDO
|
||||
if (file_exists ($file) && ! is_writeable ($file))
|
||||
throw new Exception (_("The SQLite database file is write protected"),
|
||||
500);
|
||||
if (function_exists ("posix_getuid") && fileowner ($file) === posix_getuid ())
|
||||
if (function_exists ("posix_getuid") &&
|
||||
fileowner ($file) === posix_getuid ())
|
||||
chmod ($file, 0666);
|
||||
// Force ForeignKeys support (disabled by default)
|
||||
$this->db->exec("PRAGMA foreign_keys = ON");
|
||||
@@ -255,7 +256,8 @@ class dblayer extends PDO
|
||||
{
|
||||
$table = $data[0];
|
||||
$column = $data[1];
|
||||
$req = "SELECT $column FROM `$this->prefix$table` WHERE $column=:$column";
|
||||
$req = "SELECT $column FROM `$this->tableprefix$table` ".
|
||||
"WHERE $column=:$column";
|
||||
if ($this->debug) echo "DEBUG : $req\n";
|
||||
$st = $this->db->prepare ($req);
|
||||
$val = $datasOK[$foreign];
|
||||
@@ -281,7 +283,7 @@ class dblayer extends PDO
|
||||
$column), 405);
|
||||
}
|
||||
|
||||
$req = "INSERT INTO `$this->prefix$this->table` ";
|
||||
$req = "INSERT INTO `$this->tableprefix$this->table` ";
|
||||
$req .= "(".implode (",", array_keys ($datasOK)).")";
|
||||
$req .= " VALUES ";
|
||||
$req .= "(:".implode (",:", array_keys ($datasOK)).")";
|
||||
@@ -344,7 +346,7 @@ class dblayer extends PDO
|
||||
|
||||
$req = "SELECT ";
|
||||
$req .= implode (",", $display);
|
||||
$req .= " FROM `$this->prefix$this->table`";
|
||||
$req .= " FROM `$this->tableprefix$this->table`";
|
||||
if ($select !== null)
|
||||
{
|
||||
$req .= " WHERE ";
|
||||
@@ -477,7 +479,8 @@ class dblayer extends PDO
|
||||
{
|
||||
$table = $data[0];
|
||||
$column = $data[1];
|
||||
$req = "SELECT $column FROM `$this->prefix$table` WHERE $column=:$column";
|
||||
$req = "SELECT $column FROM `$this->tableprefix$table` ".
|
||||
"WHERE $column=:$column";
|
||||
if ($this->debug) echo "DEBUG : $req\n";
|
||||
$st = $this->db->prepare ($req);
|
||||
$val = $datasOK[$foreign];
|
||||
@@ -504,7 +507,7 @@ class dblayer extends PDO
|
||||
}
|
||||
|
||||
$datasOK[$this->primary] = $updatekey;
|
||||
$req = "UPDATE `".$this->prefix."$this->table` SET ";
|
||||
$req = "UPDATE `".$this->tableprefix."$this->table` SET ";
|
||||
$i = 0;
|
||||
foreach ($datasOK as $key=>$val)
|
||||
{
|
||||
@@ -557,7 +560,7 @@ class dblayer extends PDO
|
||||
{
|
||||
if ($this->db === null)
|
||||
throw new Exception ("Database not connected");
|
||||
$req = "DELETE FROM `$this->prefix$this->table` ";
|
||||
$req = "DELETE FROM `$this->tableprefix$this->table` ";
|
||||
$req .= "WHERE $this->primary = :primary";
|
||||
$st = $this->db->prepare ($req);
|
||||
if ($this->debug) echo "DEBUG : $req\n";
|
||||
@@ -600,7 +603,7 @@ class dblayer extends PDO
|
||||
switch ($this->db->getAttribute(PDO::ATTR_DRIVER_NAME))
|
||||
{
|
||||
case "sqlite":
|
||||
$sql = "CREATE TABLE `$this->prefix$this->table` (\n";
|
||||
$sql = "CREATE TABLE `$this->tableprefix$this->table` (\n";
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field=>$params)
|
||||
{
|
||||
@@ -681,7 +684,7 @@ class dblayer extends PDO
|
||||
$sql .=")";
|
||||
break;
|
||||
case "mysql":
|
||||
$sql = "CREATE TABLE `$this->prefix$this->table` (\n";
|
||||
$sql = "CREATE TABLE `$this->tableprefix$this->table` (\n";
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field=>$params)
|
||||
{
|
||||
@@ -760,7 +763,7 @@ class dblayer extends PDO
|
||||
$sql .=") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
|
||||
break;
|
||||
case "pgsql":
|
||||
$sql = "CREATE TABLE \"$this->prefix$this->table\" (\n";
|
||||
$sql = "CREATE TABLE \"$this->tableprefix$this->table\" (\n";
|
||||
$i = 0;
|
||||
foreach ($this->fields as $field=>$params)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user