dblayeroo : suport join with CONCAT() in clause
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5159 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -4,6 +4,8 @@
|
|||||||
* @author Dominique Fournier <dominique@fournier38.fr>
|
* @author Dominique Fournier <dominique@fournier38.fr>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once ("domframework/dblayeroo.php");
|
||||||
|
|
||||||
// dblayeroo.php
|
// dblayeroo.php
|
||||||
|
|
||||||
/** Permit abstraction on the differents SQL databases available */
|
/** Permit abstraction on the differents SQL databases available */
|
||||||
@@ -2044,10 +2046,39 @@ class dblayeroo
|
|||||||
$this->DBException (sprintf (
|
$this->DBException (sprintf (
|
||||||
"Invalid field to join '%s' : not defined in Local table",
|
"Invalid field to join '%s' : not defined in Local table",
|
||||||
$fieldLocal));
|
$fieldLocal));
|
||||||
if (! array_key_exists ($fieldToJoin, $object->fields))
|
if (substr ($fieldToJoin, 0, 7) === "CONCAT(")
|
||||||
$this->DBException (sprintf (
|
{
|
||||||
"Invalid field to join '%s' : not defined in Distant table",
|
if (substr ($fieldToJoin, -1) !== ")")
|
||||||
$fieldToJoin));
|
$this->DBException ("CONCAT without ending parenthesis");
|
||||||
|
$tmp = substr ($fieldToJoin, 7, -1);
|
||||||
|
$new = "CONCAT(";
|
||||||
|
foreach (explode (",", $tmp) as $part)
|
||||||
|
{
|
||||||
|
if ($new !== "CONCAT(")
|
||||||
|
$new .= ",";
|
||||||
|
if (substr ($part, 0, 1) === "'" &&
|
||||||
|
substr ($part, -1) === "'")
|
||||||
|
$new .= $part;
|
||||||
|
elseif (! array_key_exists ($part, $object->fields))
|
||||||
|
$this->DBException (sprintf (
|
||||||
|
"Invalid field to join in CONCAT : ".
|
||||||
|
"'%s' not defined in Distant table", $part));
|
||||||
|
else
|
||||||
|
$new .=
|
||||||
|
$this->sep.$object->tableprefix.$object->table.$this->sep.".".
|
||||||
|
$this->sep.$part.$this->sep;
|
||||||
|
}
|
||||||
|
$new .= ")";
|
||||||
|
$joinArray[$fieldLocal] = $new;
|
||||||
|
}
|
||||||
|
elseif (! array_key_exists ($fieldToJoin, $object->fields))
|
||||||
|
$this->DBException (sprintf (
|
||||||
|
"Invalid field to join '%s' : not defined in Distant table",
|
||||||
|
$fieldToJoin));
|
||||||
|
else
|
||||||
|
$joinArray[$fieldLocal] =
|
||||||
|
$this->sep.$object->tableprefix.$object->table.$this->sep.".".
|
||||||
|
$this->sep.$fieldToJoin.$this->sep;
|
||||||
}
|
}
|
||||||
if (! isset ($object->table) || $object->table === null ||
|
if (! isset ($object->table) || $object->table === null ||
|
||||||
trim ($object->table) === "")
|
trim ($object->table) === "")
|
||||||
@@ -2066,9 +2097,7 @@ class dblayeroo
|
|||||||
$tmp .=
|
$tmp .=
|
||||||
$this->sep.$this->tableprefix.$this->table.$this->sep.".".
|
$this->sep.$this->tableprefix.$this->table.$this->sep.".".
|
||||||
$this->sep.$fieldLocal.$this->sep.
|
$this->sep.$fieldLocal.$this->sep.
|
||||||
"=".
|
"=$fieldToJoin";
|
||||||
$this->sep.$object->tableprefix.$object->table.$this->sep.".".
|
|
||||||
$this->sep.$fieldToJoin.$this->sep;
|
|
||||||
}
|
}
|
||||||
// Correct the displayQuery in the main display fields with the display
|
// Correct the displayQuery in the main display fields with the display
|
||||||
// fields of object
|
// fields of object
|
||||||
|
|||||||
Reference in New Issue
Block a user