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 district_id = ) ORDER BY t.updated_date DESC, t.created_date DESC, t.id DESC' at line 1. The SQL statement executed was: SELECT `t`.`id` AS `t0_c0`, `t`.`title` AS `t0_c1`, `t`.`seo_static` AS `t0_c2`, `t`.`title_seo` AS `t0_c3`, `t`.`description_seo` AS `t0_c4`, `t`.`keyword_seo` AS `t0_c5`, `t`.`brief` AS `t0_c6`, `t`.`price` AS `t0_c7`, `t`.`unit_id` AS `t0_c8`, `t`.`price_area_id` AS `t0_c9`, `t`.`thoathuan` AS `t0_c10`, `t`.`address` AS `t0_c11`, `t`.`detail` AS `t0_c12`, `t`.`dtmb` AS `t0_c13`, `t`.`dtsd` AS `t0_c14`, `t`.`width` AS `t0_c15`, `t`.`length` AS `t0_c16`, `t`.`street_id` AS `t0_c17`, `t`.`area_id` AS `t0_c18`, `t`.`project` AS `t0_c19`, `t`.`loday_id` AS `t0_c20`, `t`.`bedroom` AS `t0_c21`, `t`.`floor` AS `t0_c22`, `t`.`district_id` AS `t0_c23`, `t`.`direction_id` AS `t0_c24`, `t`.`style_id` AS `t0_c25`, `t`.`cat_id` AS `t0_c26`, `t`.`type_id` AS `t0_c27`, `t`.`status_id` AS `t0_c28`, `t`.`created_date` AS `t0_c29`, `t`.`updated_date` AS `t0_c30`, `t`.`map` AS `t0_c31`, `t`.`video` AS `t0_c32`, `t`.`hits` AS `t0_c33`, `t`.`hot` AS `t0_c34`, `t`.`vip` AS `t0_c35`, `t`.`vip_hot` AS `t0_c36`, `t`.`position_id` AS `t0_c37`, `t`.`draft` AS `t0_c38`, `t`.`active` AS `t0_c39`, `t`.`disable` AS `t0_c40`, `t`.`fullname` AS `t0_c41`, `t`.`address1` AS `t0_c42`, `t`.`mobile` AS `t0_c43`, `t`.`tag` AS `t0_c44`, `t`.`expired_date` AS `t0_c45`, `t`.`account_id` AS `t0_c46`, d.name as direction_name, dt.name as district_name, `d`.`name` AS `t1_c1`, `d`.`id` AS `t1_c0`, `dt`.`name` AS `t2_c1`, `dt`.`id` AS `t2_c0` FROM `land` `t` LEFT OUTER JOIN `direction` `d` ON (`t`.`direction_id`=`d`.`id`) LEFT OUTER JOIN `province` `dt` ON (`t`.`district_id`=`dt`.`id`) WHERE (t.active = 1 AND draft = 0 AND t.disable = 0 AND CURDATE() <= expired_date AND cat_id = AND district_id = ) ORDER BY t.updated_date DESC, t.created_date DESC, t.id DESC LIMIT 50

/home/nhadatquangtri/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

#6
+
 /home/nhadatquangtri/public_html/protected/controllers/SiteController.php(427): CActiveRecord->findAll(CDbCriteria)
422         );
423         $criteria->select = 't.*, d.name as direction_name, dt.name as district_name';
424         $criteria->condition = $condition_str;
425         $criteria->order = 't.updated_date DESC, t.created_date DESC, t.id DESC';
426         $criteria->limit = 50;
427         $search_smart = Land::model()->findAll($criteria);
428         
429         //LƯU CÁC TIÊU CHÍ TÌM KIẾM
430         $_SESSION['search_smart'] = $search;
431         $_SESSION['land_ids'][] = $model->id;
432         
#16
+
 /home/nhadatquangtri/public_html/index.php(13): CApplication->run()
08 defined('YII_DEBUG') or define('YII_DEBUG',true);
09 // specify how many levels of call stack should be shown in each log message
10 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
11 
12 require_once($yii);
13 Yii::createWebApplication($config)->run();
2024-03-19 03:35:01 Apache/2.4.53 (cPanel) OpenSSL/1.1.1o mod_bwlimited/1.4 Yii Framework/1.1.17