CDbException

CDbCommand failed to execute the SQL statement: 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 new_showhide=1 AND new_id!=' at line 1. The SQL statement executed was: SELECT COUNT(*) FROM `news` `t` WHERE id_menu= AND new_showhide=1 AND new_id!=

C:\Inetpub\vhosts\dutoan.net\framework\db\CDbCommand.php(541)

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

Stack Trace

#2
+
 C:\Inetpub\vhosts\dutoan.net\protected\controllers\home\SiteController.php(1414): CActiveRecord->count(CDbCriteria)
1409             $this->description  = $news->new_description_seo;
1410         
1411             $criteria2            = new CDbCriteria();
1412             $criteria2->condition = 'id_menu=' . $news->id_menu.' AND new_showhide=1 AND new_id!='.$news->new_id;
1413             $criteria2->order     = 'new_id DESC';
1414             $count = News::model()->count($criteria2);
1415             $pages = new CPagination($count);
1416             //results per page
1417             $pages->pageSize = 15;
1418             $pages->applyLimit($criteria2);
1419             $items = News::model()->findAll($criteria2);
#10
+
 C:\Inetpub\vhosts\dutoan.net\protected\components\WebApplicationEndBehavior.php(21): CApplication->run()
16         $this->_endName = $name;
17         // Attach the changeModulePaths event handler
18         // and raise it.
19         $this->onModuleCreate = array($this, 'changeModulePaths');
20         $this->onModuleCreate(new CEvent($this->owner));
21         $this->owner->run(); // Run application.
22     }
23     // This event should be raised when CWebApplication
24     // or CWebModule instances are being initialized.
25     public function onModuleCreate($event)
26     {
#13
+
 C:\Inetpub\vhosts\dutoan.net\index.php(8): CComponent->__call("runEnd", array("home"))
3 $config = dirname(__FILE__).'/protected/config/home.php';
4 // Remove the following lines when in production mode
5 defined('YII_DEBUG') or define('YII_DEBUG', true);
6 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL', 3);
7 require_once($yii);
8 Yii::createWebApplication($config)->runEnd('home');
9 ?>
2024-03-29 17:57:21 Microsoft-IIS/10.0 Yii Framework/1.1.13