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 last_name ASC' at line 1. The SQL statement executed was: select birdID, tenen, tenkhoahoc, tenvn, imagePC, SUBSTRING_INDEX(tenen, ' ', -1) AS last_name from bird b where birdID in () order by last_name ASC

/home/birdcom/domains/birdwatchingvietnam.net/public_html/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

#1
+
 /home/birdcom/domains/birdwatchingvietnam.net/public_html/protected/models/Bird.php(188): CDbCommand->queryAll()
183         
184         //$sql = 'select c.birdID, c.tenen, c.imagePC, substring(tenen,pos+1) AS last_name from (SELECT b.*, instr(b.tenen," ") AS pos FROM bird b) as c order by last_name ASC ';
185         $sql = "select birdID, tenen, tenkhoahoc, tenvn, imagePC, SUBSTRING_INDEX(tenen, ' ', -1) AS last_name from  bird b where birdID in (" . $ids . ") order by last_name ASC ";
186         $data = Yii::app()->db
187             ->createCommand($sql)
188             ->queryAll();
189         
190         $birdlist = array();
191         
192         for($x=0;$x<count($data); $x++){
193             $obj = new Bird();//Bird::model();
#2
+
 /home/birdcom/domains/birdwatchingvietnam.net/public_html/protected/controllers/PhotographerController.php(17): Bird->getBirdByEnglishNameAndIds("")
12             $criteria->select = 'birdID';
13             $listbirdid = Birdimages::model()->findAll($criteria);
14             
15             $arr = CHtml::listData($listbirdid, 'birdID', 'birdID');
16             $ids = implode(",",$arr);
17             $birdlist = Bird::model()->getBirdByEnglishNameAndIds($ids);
18             
19             $tempBirdimages = Birdimages::model()->find("photographer like '" . $searchby . "'");
20         }
21         // Data
22         $data = array(
#10
+
 /home/birdcom/domains/birdwatchingvietnam.net/public_html/index.php(12): CApplication->run()
07 defined('YII_DEBUG') or define('YII_DEBUG',true);
08 // specify how many levels of call stack should be shown in each log message
09 //defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
10 require_once($yii);
11 
12 Yii::createWebApplication($config)->run();
13 
14 
2024-03-29 16:47:02 Apache/2 Yii Framework/1.1.13