We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

phql issue

Code:

$query = $this->modelsManager->createQuery("SELECT id,first_name,last_name,contact_email from Contacts where flag=1 UNION ALL SELECT id,first_name,last_name,bounce_email_address from MailchimpImportContacts where flag=1");
$contacts = $query->execute();**

Hello Friends When I used above query getting error such as :

Syntax error, unexpected token IDENTIFIER(UNION), near to ' ALL SELECT id,first_name,last_name,bounce_email_address from MailchimpImportContacts where flag=1', when parsing: SELECT id,first_name,last_name,contact_email from Contacts where flag=1 UNION ALL SELECT id,first_name,last_name,bounce_email_address from MailchimpImportContacts where flag=1 (175)

How to resolve it



58.4k

Hey

This is code below working in phpmyadmin yet ?

SELECT id,firstname,lastname,contact_email from Contacts where flag=1 UNION ALL SELECT id,first_name,lastname,bounceemail_address from MailchimpImportContacts where flag=1


8.7k

Hey

This is code below working in phpmyadmin yet ?

SELECT id,firstname,lastname,contact_email from Contacts where flag=1 UNION ALL SELECT id,first_name,lastname,bounceemail_address from MailchimpImportContacts where flag=1

Yes I know but not working in phalcon when I try to execute.



8.7k

Syntax error, unexpected token IDENTIFIER(UNION), near to ' SELECT id,first_name,last_name,bounce_email_address from MailchimpImportContacts where flag=1', when parsing: SELECT id,first_name,last_name,contact_email from Contacts where flag=1 UNION SELECT id,first_name,last_name,bounce_email_address from MailchimpImportContacts where flag=1 (196)

UNION is probably not supported in PHQL yet :/



8.7k

What is alternative method for it?

I use Raw SQL: https://docs.phalcon.io/en/latest/reference/phql.html#using-raw-sql but i can't receive data How to use using-raw-sql and receive data? thanks.