CDbException

CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'rating' in order clause is ambiguous. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`state` AS `t0_c1`, `t`.`parentId` AS `t0_c2`, `t`.`chpu` AS `t0_c3`, `t`.`title` AS `t0_c4`, `t`.`description` AS `t0_c5`, `t`.`description_small` AS `t0_c6`, `t`.`regionId` AS `t0_c7`, `t`.`cityId` AS `t0_c8`, `t`.`streetId` AS `t0_c9`, `t`.`home` AS `t0_c10`, `t`.`corpus` AS `t0_c11`, `t`.`building` AS `t0_c12`, `t`.`apartment` AS `t0_c13`, `t`.`site` AS `t0_c14`, `t`.`logoId` AS `t0_c15`, `t`.`sectionId` AS `t0_c16`, `t`.`oldId` AS `t0_c17`, `t`.`service` AS `t0_c18`, `t`.`advCompanyId` AS `t0_c19`, `t`.`usedAdvertCount` AS `t0_c20`, `t`.`newAdvertCount` AS `t0_c21`, `t`.`utilization` AS `t0_c22`, `t`.`rating` AS `t0_c23`, `t`.`stars` AS `t0_c24`, `t`.`coordFi` AS `t0_c25`, `t`.`coordLam` AS `t0_c26`, t.title AS ttitle, `region`.`id` AS `t1_c0`, `region`.`title` AS `t1_c1`, `city`.`id` AS `t2_c0`, `city`.`regionId` AS `t2_c1`, `city`.`title` AS `t2_c2`, `street`.`id` AS `t3_c0`, `street`.`regionId` AS `t3_c1`, `street`.`cityId` AS `t3_c2`, `street`.`title` AS `t3_c3`, `section`.`id` AS `t5_c0`, `section`.`title` AS `t5_c1`, `section`.`title_one` AS `t5_c2`, `section`.`chpu` AS `t5_c3`, `section`.`sort` AS `t5_c4`, `section`.`rating` AS `t5_c5` FROM `tc_company` `t` LEFT OUTER JOIN `tc_address_region` `region` ON (`t`.`regionId`=`region`.`id`) LEFT OUTER JOIN `tc_address_city` `city` ON (`t`.`cityId`=`city`.`id`) LEFT OUTER JOIN `tc_address_street` `street` ON (`t`.`streetId`=`street`.`id`) LEFT OUTER JOIN `tc_company_section` `section` ON (`t`.`sectionId`=`section`.`id`) WHERE (t.sectionId=:sectionId AND t.state=1) ORDER BY t.service desc, rating DESC LIMIT 15. Bound with :sectionId='4'

/var/www/tpona/data/yiiframework/yii-1.1.14.f0fee9/framework/yiilite.php(9341)

9329             return $result;
9330         }
9331         catch(Exception $e)
9332         {
9333             if($this->_connection->enableProfiling)
9334                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
9335             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
9336             $message=$e->getMessage();
9337             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
9338                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
9339             if(YII_DEBUG)
9340                 $message.='. The SQL statement executed was: '.$this->getText().$par;
9341             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
9342                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
9343         }
9344     }
9345     public function buildQuery($query)
9346     {
9347         $sql=!empty($query['distinct']) ? 'SELECT DISTINCT' : 'SELECT';
9348         $sql.=' '.(!empty($query['select']) ? $query['select'] : '*');
9349         if(!empty($query['from']))
9350             $sql.="\nFROM ".$query['from'];
9351         else
9352             throw new CDbException(Yii::t('yii','The DB query must contain the "from" portion.'));
9353         if(!empty($query['join']))

Stack Trace

#11
+
 /var/www/tpona/data/www/tvercars.ru/www/protected/components/FrontController.php(70): CBaseController->createWidget("zii.widgets.CListView", array("dataProvider" => CActiveDataProvider, "ajaxUpdate" => false, "itemView" => "_view", "sorterHeader" => "Сортировать:", ...))
65     
66     public function widget($className,$properties=array(),$captureOutput=false)
67     {
68         $res = false;
69 
70         $widget=$this->createWidget($className,$properties);
71         
72         if (isset($widget->cache_id) && $widget->cache_id)
73         {
74             $res = Yii::app()->cache->get($widget->cache_id);
75         }
#12
+
 /var/www/tpona/data/www/tvercars.ru/www/protected/views/company/index.php(22): FrontController->widget("zii.widgets.CListView", array("dataProvider" => CActiveDataProvider, "ajaxUpdate" => false, "itemView" => "_view", "sorterHeader" => "Сортировать:", ...))
17             'stars'=>'по звездам',
18         ),
19         'pager' => array(
20             'cssFile' => Yii::app()->getBaseUrl(true) . '/css/pager.css'
21         ),
22     ));
23 ?>
24 </div>
#17
+
 /var/www/tpona/data/www/tvercars.ru/www/protected/controllers/CompanyController.php(539): CController->render("index", array("dataProvider" => CActiveDataProvider, "menu" => array(CompanySection, CompanySection, CompanySection, CompanySection, ...), "section" => CompanySection))
534         
535         $this->render('index', array(
536             'dataProvider'  => $dataProvider,
537             'menu'          => $menu,
538             'section'          => $section,
539         ));
540     }
541     
542     public function actionSection($chpu) {
543         $this->sectionList($chpu, 'index');
544     }
2024-03-28 20:42:15 Apache/2.4.29 (Ubuntu) Yii Framework/1.1.14