My oryginal query is
SELECT Parts.partid FROM Parts LEFT JOIN Pages ON(Pages.datasource_id=Parts.partid AND Pages.page_language=Parts.lang ) LEFT JOIN PartsModyfication ON(PartsModyfication.id=Parts.id) WHERE Parts.sparte LIKE :sparte: AND Parts.lang =:lang: AND IF(PartsModyfication.partsel <> "" OR PartsModyfication.partsel IS NOT NULL,PartsModyfication.partsel,Parts.partsel) like :partsel: ORDER BY dateupdate DESC
When I run it via executeQuery
$partes = $this->modelsManager->executeQuery( $sQuery, $bind );
Phalcon produce query without table aliases in IF statement
SELECT parts
.partid
AS partid
FROM parts
LEFT JOIN pages
ON (pages
.datasource_id
= parts
.partid
AND pages
.page_language
= parts
.lang
) LEFT JOIN parts_modyfication
ON (parts_modyfication
.id
= parts
.id
) WHERE parts
.sparte
LIKE :sparte AND parts
.lang
= :lang AND IF(partsel
<> '' OR partsel
IS NOT NULL, partsel
, partsel
) LIKE :partsel ORDER BY dateupdate
DESC
It coses sql partsel ambiguous partsel
column name problem.
Is there any fix for that?