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 `user2`=42)OR(`user1`=42 AND `user2`=)' at line 1. The SQL statement executed was: SELECT * FROM `messages_conversation` `t` WHERE (`user1`= AND `user2`=42)OR(`user1`=42 AND `user2`=)

/mnt/volume-fra1-01/www/photonews.ru/framework/yiilite.php(8626)

8614             return $result;
8615         }
8616         catch(Exception $e)
8617         {
8618             if($this->_connection->enableProfiling)
8619                 Yii::endProfile('system.db.CDbCommand.query('.$this->getText().$par.')','system.db.CDbCommand.query');
8620             $errorInfo = $e instanceof PDOException ? $e->errorInfo : null;
8621             $message = $e->getMessage();
8622             Yii::log(Yii::t('yii','CDbCommand::{method}() failed: {error}. The SQL statement executed was: {sql}.',
8623                 array('{method}'=>$method, '{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
8624             if(YII_DEBUG)
8625                 $message .= '. The SQL statement executed was: '.$this->getText().$par;
8626             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
8627                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
8628         }
8629     }
8630     public function buildQuery($query)
8631     {
8632         $sql=isset($query['distinct']) && $query['distinct'] ? 'SELECT DISTINCT' : 'SELECT';
8633         $sql.=' '.(isset($query['select']) ? $query['select'] : '*');
8634         if(isset($query['from']))
8635             $sql.="\nFROM ".$query['from'];
8636         else
8637             throw new CDbException(Yii::t('yii','The DB query must contain the "from" portion.'));
8638         if(isset($query['join']))

Stack Trace

#3
+
 /mnt/volume-fra1-01/www/photonews.ru/protected/controllers/frontend/ConversationsController.php(43): CActiveRecord->findAll(CDbCriteria)
38         $u=Yii::app()->user->getId();
39         $t=$id;
40     $criteria= new CDbCriteria;
41     $criteria->condition="(`user1`={$u} AND `user2`={$t})OR(`user1`={$t} AND `user2`={$u})";
42     
43     $d=Conversation::model()->findAll($criteria);
44     if (isset($d[0])){
45         $this->redirect("/conversations/{$d[0]->id}");
46     }else{
47         $c=new Conversation;
48         $c->user1=$u;
#13
+
 /mnt/volume-fra1-01/www/photonews.ru/protected/behaviors/WebApplicationEndBehavior.php(23): CApplication->run()
18         $this->_endName = $name;
19         
20         // обрабатываем событие создания модуля
21         $this->onModuleCreate = array($this, 'changeModulePaths');
22         $this->onModuleCreate(new CEvent ($this->owner));
23         $this->owner->run();
24         
25     }
26     
27     // обработчик события onModuleCreate
28     public function onModuleCreate($event)
#16
+
 /mnt/volume-fra1-01/www/photonews.ru/index.php(20): CComponent->__call("runEnd", array("frontend"))
15 defined('YII_DEBUG') or define('YII_DEBUG',true);
16 // specify how many levels of call stack should be shown in each log message
17 //defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);
18 
19 require_once($yii);
20 Yii::createWebApplication($config)->runEnd('frontend');
21  
2024-03-19 14:46:55 Apache/2.4.18 (Ubuntu) mpm-itk/2.4.7-04 PHP/5.6.30-10+deb.sury.org~xenial+2 OpenSSL/1.0.2g Yii Framework/1.1.8