Skip to content

How to convert this SQL to PHQL? #16666

Answered by ftugit
ftugit asked this question in Q&A
Nov 19, 2024 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

In the end, I wrote an analog of GROUP_CONCAT. A questionable implementation of the desired SQL.

registerCustomFunction('JOINSELECT', function ($dialect, $expression) {
            $arguments = $expression['arguments'];

            $table = (new (trim($arguments[1]['value'], '\'')))->getSource();
            $field = $arguments[0]['value'];
            $where = trim($arguments[2]['value'], '\'');
            $id = $dialect->getSqlExpression($arguments[3]);
            $comparator = trim($arguments[4]['value'], '\'');
            $limit = empty($arguments[5]) !== true ? $arguments[5]['value'] : 5;

            // JOINSELECT("name", "App\Models\CollectionNames", "collection_id", "=", id, "…

Replies: 2 comments 1 reply

Comment options

niden
Nov 19, 2024
Maintainer Sponsor

You must be logged in to vote
1 reply
@ftugit
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by ftugit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants