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 'ORDER BY RAND() LIMIT 7' at line 1. The SQL statement executed was: SELECT * FROM `products` `t` WHERE cat_name_sub = ORDER BY RAND() LIMIT 7

/home/fixtoysn/domains/fixtoys.net/public_html/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
+
 /home/fixtoysn/domains/fixtoys.net/public_html/protected/controllers/ProductsController.php(395): CActiveRecord->findAll(CDbCriteria)
390         $newProductlists = '';
391         $criteria = new CDbCriteria();
392         $criteria->condition = 'cat_name_sub = '.$catNameNameId;
393         $criteria->order = 'RAND()';
394         $criteria->limit = 7;
395         $newProductlists = Products::model()->findAll($criteria);
396         
397         if(empty($newProductlists)){
398             $criteria = new CDbCriteria();
399             $criteria->condition = 'cat_name_main = '.$catSubNameId;
400             $criteria->order = 'RAND()';
#13
+
 /home/fixtoysn/domains/fixtoys.net/public_html/index.php(14): CApplication->run()
09 defined('YII_DEBUG') or define('YII_DEBUG',TRUE);
10 // specify how many levels of call stack should be shown in each log message
11 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
12 
13 require_once($yii);
14 Yii::createWebApplication($config)->run();
15  
2024-03-28 23:40:57 Apache/2 Yii Framework/1.1.15