Couldn’t get short alias for (

The below query didn’t worked for me and gave me the error “Couldn’t get short alias for ( re” and so i did removed the spaces from between every ‘or’ and brackets ‘(‘. i have added the modified query below the original query.

$restaurant = Doctrine_Query::create()
->select(‘re.*’)
->from(‘ReservationHoursSetting re’)
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( (re.hr_from > {$hourFrom} AND re.hr_from < {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) )”, array($HourID, $restaurantSettingID) )
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( ( re.hr_from BETWEEN {$hourFrom} AND {$hourTo} ) OR ( re.hr_to BETWEEN {$hourFrom} AND {$hourTo} ) OR ( {$hourFrom} BETWEEN re.hr_from AND re.hr_to )  OR ( {$hourTo} BETWEEN re.hr_from AND re.hr_to ) )”, array($HourID,$restaurantSettingID) )
->where(“re.id <> ? AND re.reservation_setting_id = ? “, array($HourID,$restaurantSettingID) )
->andWhere(“((re.hr_from > {$hourFrom}  AND re.hr_from< {$hourTo})

OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo})

OR (re.hr_to > {$hourFrom}  AND re.hr_from < {$hourFrom})

OR (re.hr_to < {$hourTo}  AND re.hr_from > {$hourTo})

OR (re.hr_to = {$hourTo}  AND re.hr_from = {$hourFrom}))”)
->fetchArray();

====================

$restaurant = Doctrine_Query::create()
->select(‘re.*’)
->from(‘ReservationHoursSetting re’)
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( (re.hr_from > {$hourFrom} AND re.hr_from < {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) )”, array($HourID, $restaurantSettingID) )
//->where(“re.id <> ? AND re.reservation_setting_id = ? AND ( ( re.hr_from BETWEEN {$hourFrom} AND {$hourTo} ) OR ( re.hr_to BETWEEN {$hourFrom} AND {$hourTo} ) OR ( {$hourFrom} BETWEEN re.hr_from AND re.hr_to )  OR ( {$hourTo} BETWEEN re.hr_from AND re.hr_to ) )”, array($HourID,$restaurantSettingID) )
->where(“re.id <> ? AND re.reservation_setting_id = ? “, array($HourID,$restaurantSettingID) )
->andWhere(“((re.hr_from > {$hourFrom}  AND re.hr_from< {$hourTo}) OR (re.hr_to > {$hourFrom} AND re.hr_to < {$hourTo}) OR (re.hr_to > {$hourFrom}  AND re.hr_from < {$hourFrom}) OR (re.hr_to < {$hourTo}  AND re.hr_from > {$hourTo}) OR (re.hr_to = {$hourTo}  AND re.hr_from = {$hourFrom}))”)
->fetchArray();

Leave a comment