dblayeroo : remove the tables names if there is no collision risk. The display table is not necessary the $this->table one.
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5259 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -3235,7 +3235,7 @@ class dblayeroo
|
|||||||
// name to the value by index.
|
// name to the value by index.
|
||||||
// FETCH_ASSOC doesn't work in empty left join (return NULL instead of
|
// FETCH_ASSOC doesn't work in empty left join (return NULL instead of
|
||||||
// the filled value)
|
// the filled value)
|
||||||
$fieldsAll = $this->fieldsAll (false);
|
$fieldsAll = $this->fieldsAll (true);
|
||||||
// If the displayed fields are all in the same table, remove the table
|
// If the displayed fields are all in the same table, remove the table
|
||||||
// name in the columns
|
// name in the columns
|
||||||
$cleanable = true;
|
$cleanable = true;
|
||||||
@@ -3252,18 +3252,22 @@ class dblayeroo
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$columns = array_values ($this->displayGet (true));
|
||||||
|
// Get the columns names that will be displayed to user.
|
||||||
|
// If the cleanable is possible, remove the table names
|
||||||
|
$columnNames = array_combine ($columns, $columns);
|
||||||
//if ($this->joinObject === null && count ($this->displayGet (false)))
|
//if ($this->joinObject === null && count ($this->displayGet (false)))
|
||||||
if ($cleanable)
|
if ($cleanable)
|
||||||
{
|
{
|
||||||
// Force the fields to local ones as there is no use of external fields
|
|
||||||
$fieldsAll = $this->fields;
|
|
||||||
// Remove the table name as there is no collisions risk
|
// Remove the table name as there is no collisions risk
|
||||||
// In case of Alias, remove the $this->sep too
|
// In case of Alias, remove the $this->sep too
|
||||||
$columns = array ();
|
foreach ($columnNames as $key => $col)
|
||||||
foreach ($this->displayGet (false) as $col)
|
|
||||||
{
|
{
|
||||||
$col = str_replace ($this->sep.$this->tableprefix.$this->table.
|
// Remove the table and the separator if exists
|
||||||
$this->sep.".", "", $col);
|
$col = preg_replace ("#".$this->sep."[^".$this->sep."]+".
|
||||||
|
$this->sep."\.#U", "", $col);
|
||||||
|
// Remove the separator if not table exists
|
||||||
|
$col = str_replace ($this->sep, "", $col);
|
||||||
if ($col[0] === $this->sep)
|
if ($col[0] === $this->sep)
|
||||||
$col = substr ($col, 1);
|
$col = substr ($col, 1);
|
||||||
elseif (strpos ($col, "DISTINCT ".$this->sep) === 0)
|
elseif (strpos ($col, "DISTINCT ".$this->sep) === 0)
|
||||||
@@ -3279,14 +3283,16 @@ class dblayeroo
|
|||||||
$col = substr ($col, 0, strpos ($col, " AS ".$this->sep) -1).
|
$col = substr ($col, 0, strpos ($col, " AS ".$this->sep) -1).
|
||||||
substr ($col, strpos ($col, " AS ".$this->sep));
|
substr ($col, strpos ($col, " AS ".$this->sep));
|
||||||
}
|
}
|
||||||
$columns[] = $col;
|
$columnNames[$key] = $col;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$columns = $this->displayGet (true);
|
foreach ($columnNames as $key => $col)
|
||||||
|
{
|
||||||
|
$columnNames[$key] = str_replace ($this->sep, "", $col);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$columns = array_values ($columns);
|
|
||||||
foreach ($result as $rownb=>$row)
|
foreach ($result as $rownb=>$row)
|
||||||
{
|
{
|
||||||
foreach ($row as $colNb=>$val)
|
foreach ($row as $colNb=>$val)
|
||||||
@@ -3308,6 +3314,9 @@ class dblayeroo
|
|||||||
if ($pos)
|
if ($pos)
|
||||||
$name = substr ($columns[$colNb], 0, $pos);
|
$name = substr ($columns[$colNb], 0, $pos);
|
||||||
$name = str_replace ("DISTINCT ", "", $name);
|
$name = str_replace ("DISTINCT ", "", $name);
|
||||||
|
/*if ($cleanable)
|
||||||
|
$name = str_replace ($this->sep.$this->tableprefix.$this->table.
|
||||||
|
$this->sep.".", "", $name);*/
|
||||||
if (strtolower ($fieldsAll[$name][0]) === "integer" &&
|
if (strtolower ($fieldsAll[$name][0]) === "integer" &&
|
||||||
$val !== null)
|
$val !== null)
|
||||||
$val = intval ($val);
|
$val = intval ($val);
|
||||||
@@ -3318,7 +3327,7 @@ class dblayeroo
|
|||||||
$colName = substr ($columns[$colNb], $pos, -1);
|
$colName = substr ($columns[$colNb], $pos, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$colName = str_replace ($this->sep, "", $columns[$colNb]);
|
$colName = $columnNames[$columns[$colNb]];
|
||||||
$result[$rownb][$colName] = $val;
|
$result[$rownb][$colName] = $val;
|
||||||
unset ($result[$rownb][$colNb]);
|
unset ($result[$rownb][$colNb]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user