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 'ORDER BY t.ord ASC, t.id DESC' at line 1. The SQL statement executed was: SELECT * FROM `cat` `t` WHERE t.active = 1 AND parent = ORDER BY t.ord ASC, t.id DESC

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

#3
+
 /home/jiayanghk/public_html/protected/models/Cat.php(230): CActiveRecord->findAll(array("condition" => "t.active = 1 AND parent = ", "order" => "t.ord ASC, t.id DESC"))
225         }
226 
227         return self::model()->findAll(array(
228             'condition' => "t.active = 1 AND parent = $pare $sql",
229             'order' => 't.ord ASC, t.id DESC'
230         ));
231     }
232 
233     public function getProductCatDDL()
234     {    
235         $arr = array();
#4
+
 /home/jiayanghk/public_html/protected/controllers/SiteController.php(226): Cat->getCatByParent(null)
221         /* Begin */
222         $this->page_init();
223         $this->plugins[] = 'flexslider';
224 
225         $cat     = Cat::model()->findByPk( $id );
226         $sub     = Cat::model()->getCatByParent( $cat->id );
227         $arr     = array( $cat->id );
228         foreach($sub as $s):
229             $arr[] = $s->id;
230             $sub2 = Cat::model()->getCatByParent( $s->id );
231             foreach($sub2 as $s2)
#14
+
 /home/jiayanghk/public_html/index.php(16): CApplication->run()
11 defined('YII_DEBUG') or define('YII_DEBUG',true);
12 // specify how many levels of call stack should be shown in each log message
13 defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
14 
15 require_once($yii);
16 Yii::createWebApplication($config)->run();
2024-03-19 18:33:23 LiteSpeed Yii Framework/1.1.7