Hi,
I have some raw-sql queries, which I want translate to PHQL. For example:
raq sql:
UPDATE versions
LEFT JOIN composerlink ON composerlink.TrackRef=versions.TrackRef
SET Price=PriceOrig
WHERE composerlink.ComposerRef=:artistId
AND (Price=0) OR (Price IS NULL)
And PHQL query of this sql query:
public static function updateVersions($artistId)
{
$artist = new Artist();
$phql = "
UPDATE Version
LEFT JOIN RelArtistTrack ON RelArtistTrack.TrackRef=Version.TrackRef
SET Version.Price=Version.PriceOrig
WHERE RelArtistTrack.ComposerRef=:artistId:
AND (Version.Price=0) OR (Version.Price IS NULL)
";
$result = $artist->getModelsManager()->executeQuery($phql, ['artistId' => $artistId]);
}
So, it's very simple UPDATE query with JOIN. But after executing this query I see an error:
Phalcon\Mvc\Model\Exception: Syntax error, unexpected token LEFT, near to ' JOIN RelArtistTrack ON RelArtistTrack.TrackRef=Version.TrackRef\n SET Version.Price=Version.PriceOrig\n WHERE RelArtistTrack.ComposerRef=:artistId:\n AND (Version.Price=0) OR (Version.Price IS NULL)\n ', when parsing: \n UPDATE Version\n LEFT JOIN RelArtistTrack ON RelArtistTrack.TrackRef=Version.TrackRef\n SET Version.Price=Version.PriceOrig\n WHERE RelArtistTrack.ComposerRef=:artistId:\n AND (Version.Price=0) OR (Version.Price IS NULL)\n (231)
If I understand correctly, these types of PHQL queries are not supported? Or this is a bug?