CDbException

CDbCommand không thể thi hành câu truy vấn 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 c.id=
ORDER BY posted_date DESC, n.id DESC
LIMIT 0,4' at line 5. The SQL statement executed was: SELECT n.*, c.url as cat_url, c.name as cat_name
FROM news n
INNER JOIN `languages` lang ON lang.id = n.lang_id AND lang.code like 'vi'
LEFT JOIn `cat_news` c ON c.id = n.cat_id
WHERE n.active = 1 AND n.id <> AND c.id=
ORDER BY posted_date DESC, n.id DESC
LIMIT 0,4

/home/hsdnorth/public_html/framework/db/CDbCommand.php(518)

506             return $result;
507         }
508         catch(Exception $e)
509         {
510             if($this->_connection->enableProfiling)
511                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
512             $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;
513             $message = $e->getMessage();
514             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
515                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
516             if(YII_DEBUG)
517                 $message .= '. The SQL statement executed was: '.$this->getText().$par;
518             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
519                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
520         }
521     }
522 
523     /**
524      * Builds a SQL SELECT statement from the given query specification.
525      * @param array $query the query specification in name-value pairs. The following
526      * query options are supported: {@link select}, {@link distinct}, {@link from},
527      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
528      * {@link limit}, {@link offset} and {@link union}.
529      * @return string the SQL statement
530      * @since 1.1.6

Stack Trace

#1
+
 /home/hsdnorth/public_html/protected/components/site/CNewsGrid.php(33): CDbCommand->queryAll()
28         WHERE n.active = 1 $con
29         ORDER BY posted_date DESC, n.id DESC
30         LIMIT {$this->offset},{$this->limit}";
31         $cn = Yii::app()->db; 
32         $cmd = $cn->createCommand($sql);
33         $data['news'] = $cmd->queryAll(); 
34         
35         
36         $this->render('news_grid',$data);
37     }
38 }
#3
+
 /home/hsdnorth/public_html/protected/views/site/pages/news.php(34): CBaseController->widget("application.components.site.CNewsGrid", array("limit" => 4, "offset" => 0, "excTitle" => 11, "excBrief" => 13, ...))
29         <br class="clear" />
30         <div class="fb-comments" data-href="<?=$this->page_url?>" data-width="100%" data-numposts="5" data-colorscheme="light"></div>
31         <div class="line"></div>
32         <h2><?=Yii::t('app','same_category_news')?></h2>
33         <ul class="ngrid">
34             <? $this->widget('application.components.site.CNewsGrid',array('limit'=>4,'offset'=>0,'excTitle'=>11,'excBrief'=>13,'arg'=>array('!n.id'=>$model->id,'c.id'=>$model->cat_id))); ?>
35         </ul>
36         </div><div class="right">
37             <? $this->renderPartial('right'); ?>
38         </div>
39     </div>
#8
+
 /home/hsdnorth/public_html/protected/controllers/SiteController.php(214): CController->render("pages/news", array("model" => null))
209         
210         $this->page_name = $model->title . ' | ' . $this->page_name;
211         $this->page_desc = $model->title . ' | ' . $this->page_desc;
212         $this->page_url = 'http://'.$_SERVER['SERVER_NAME'].Yii::app()->createUrl('site/News', array('any' => myExt::KhongDau($model->cat->name), 'cat' => $model->cat_id, 'id' => $model->id, 'title' => myExt::KhongDau($model->title)));
213         $this->layout = '//layouts/page';
214         $this->render('pages/news', array('model' => $model));
215     }
216     
217     public function actionPage($id)
218     {
219         if (!Yii::app()->session['lang'])    Languages::setLanguage(); else     Yii::app()->language = Yii::app()->session['lang'];
2024-03-28 22:01:44 Apache/2.4.53 (cPanel) OpenSSL/1.1.1o mod_bwlimited/1.4 Yii Framework/1.1.7