简体   繁体   中英

Symfony2 and Doctrine: createQuery error

I am trying to run this query:

$query =  $this->getEntityManager()
    ->createQuery(
            'SELECT MDPIBackendBundle:Articles   
            FROM MDPIBackendBundle:Articles art
            LEFT JOIN MDPIBackendBundle:ScopusFTPUploads uploaded_art WITH art.id = uploaded_art.article_id
            WHERE uploaded_art.article_id IS NULL AND art.pubdate_published >= "'.$startDate.'" AND art.pubdate_published < "'.$endDate.'"'
    );

And I am geting this error:

[Syntax Error] line 0, col 272: Error: Expected Literal, got '"' 

Do you know where is the problem? Thank you.

It seems like a typo, you cant use " in sql / dql . Try:

$query =  $this->getEntityManager()
    ->createQuery(
            "SELECT MDPIBackendBundle:Articles   
            FROM MDPIBackendBundle:Articles art
            LEFT JOIN MDPIBackendBundle:ScopusFTPUploads uploaded_art WITH art.id = uploaded_art.article_id
            WHERE uploaded_art.article_id IS NULL AND art.pubdate_published >= '".$startDate."' AND art.pubdate_published < '".$endDate."');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM