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 MariaDB server version for the right syntax to use near 'AND cat_id = ORDER BY id DESC LIMIT 3' at line 1. The SQL statement executed was: SELECT * FROM `news` `t` WHERE active = 1 AND id < AND cat_id = ORDER BY id DESC LIMIT 3

C:\inetpub\vhosts\thanhlapdoanhnghiephaiphong.vn\httpdocs\framework\db\CDbCommand.php(543)

531         {
532             if($this->_connection->enableProfiling)
533                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
534 
535             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
536             $message=$e->getMessage();
537             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
538                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
539 
540             if(YII_DEBUG)
541                 $message.='. The SQL statement executed was: '.$this->getText().$par;
542 
543             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
544                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
545         }
546     }
547 
548     /**
549      * Builds a SQL SELECT statement from the given query specification.
550      * @param array $query the query specification in name-value pairs. The following
551      * query options are supported: {@link select}, {@link distinct}, {@link from},
552      * {@link where}, {@link join}, {@link group}, {@link having}, {@link order},
553      * {@link limit}, {@link offset} and {@link union}.
554      * @throws CDbException if "from" key is not present in given query parameter
555      * @return string the SQL statement

Stack Trace

#3
+
 C:\inetpub\vhosts\thanhlapdoanhnghiephaiphong.vn\httpdocs\protected\models\News.php(149): CActiveRecord->findAll(array("condition" => "active = 1 AND id < AND cat_id = ", "order" => "id DESC", "limit" => 3))
144     {
145         return self::model()->findAll(array(
146         'condition' => 'active = 1 AND id < ' . $id . ' AND cat_id = ' . $cat,
147         'order' => 'id DESC',
148         'limit' => 3,
149         ));
150     }
151     
152     public function getNewNews()
153     {
154         return self::model()->with('cat', 'lang')->findAll(array(
#4
+
 C:\inetpub\vhosts\thanhlapdoanhnghiephaiphong.vn\httpdocs\protected\views\site\pages\news.php(34): News->getOrther(null, null)
29                         </div>
30                         
31 
32                         <br class="clear_left" />
33                         <?php
34                         $orther = News::getOrther($model->id, $model->cat_id);
35                         if (count($orther) > 0)
36                         {
37                             ?>
38                             <div class="related_news_page">
39                                 <p><strong>Bài viết liên quan</strong></p>
#9
+
 C:\inetpub\vhosts\thanhlapdoanhnghiephaiphong.vn\httpdocs\protected\controllers\SiteController.php(284): CController->render("pages/news", array("model" => null))
279         {
280             $this->navigation_bar = $this->navigation_bar  . CHtml::link($model->cat->cat->name, Yii::app()->urlManager->createUrl('site/listnews', array('id' => $model->cat->parent, 'name' => myExt::KhongDau($model->cat->cat->name))));
281         }
282         $this->navigation_bar = $this->navigation_bar  . CHtml::link($model->cat->name, Yii::app()->urlManager->createUrl('site/listnews', array('id' => $model->cat_id, 'name' => myExt::KhongDau($model->cat->name))));
283 
284         $this->render('pages/news', array('model' => $model));
285     }
286 
287     public function actionListNews($id, $name)
288     {
289         if (!Yii::app()->session['lang'])
2024-03-28 20:08:59 Microsoft-IIS/10.0 Yii Framework/1.1.14