Кто разбирается в синтаксе SQL, помогите исправить ошибку.
Фреймворк Yii, ошибка:
CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') AND i.is_main=1' at line 5
WHERE a.id IN".$apartmentArr." AND i.is_main=1 ORDER BY a.date_created DESC";
<?php class HotDealsPaidService extends PaidServices{ public static function getHotDeals(){ $apartmentArr = ''; $apartmentPaid = ApartmentPaid::model()->findAll(); /* $apartmentPaid = ApartmentPaid::model()->findAllByAttributes(array( 'paid_id' => PaidServices::ID_HOT_OFFER, )); */ foreach($apartmentPaid as $offer){ $apartmentArr .= $offer->apartment_id.','; } } $sql = " SELECT a.id, a.type,a.price, a.city_id, i.file_name_modified, a.date_created, c.name_ru, a.title_".Yii::app()->language." AS title FROM {{apartment}} a INNER JOIN {{apartment_city}} c ON c.id = a.city_id INNER JOIN {{images}} i ON i.id_object = a.id WHERE a.id IN".$apartmentArr." AND i.is_main=1 ORDER BY a.date_created DESC"; $result = Yii::app()->db->createCommand($sql)->queryAll(true); $i=0; foreach ($result as $apartment){ $result[$i]['type'] = Apartment::getNameByType($apartment['type']); $result[$i]['file_name_modified'] = '/uploads/objects/'.$apartment['id'].'/modified/full_'.$apartment['file_name_modified']; $i++; } return $result; } } ?>