CDbException

CDbCommand не удалось исполнить SQL-запрос: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '/faq/26-v_opisanii_alboma_mozhno_proverit_tekst_na_unikalnost_ch' for key 'url'. The SQL statement executed was: INSERT INTO `hm2_seo` (`url`) VALUES (:yp0). Bound with :yp0='/faq/26-v_opisanii_alboma_mozhno_proverit_tekst_na_unikalnost_chto_eto_oznachaet_i_na_chto_eto_vliyaet'

/var/www/happymoments.ua/web/protected/vendor/yiisoft/yii/framework/db/CDbCommand.php(358)

346         {
347             if($this->_connection->enableProfiling)
348                 Yii::endProfile('system.db.CDbCommand.execute('.$this->getText().$par.')','system.db.CDbCommand.execute');
349 
350             $errorInfo=$e instanceof PDOException ? $e->errorInfo : null;
351             $message=$e->getMessage();
352             Yii::log(Yii::t('yii','CDbCommand::execute() failed: {error}. The SQL statement executed was: {sql}.',
353                 array('{error}'=>$message, '{sql}'=>$this->getText().$par)),CLogger::LEVEL_ERROR,'system.db.CDbCommand');
354 
355             if(YII_DEBUG)
356                 $message.='. The SQL statement executed was: '.$this->getText().$par;
357 
358             throw new CDbException(Yii::t('yii','CDbCommand failed to execute the SQL statement: {error}',
359                 array('{error}'=>$message)),(int)$e->getCode(),$errorInfo);
360         }
361     }
362 
363     /**
364      * Executes the SQL statement and returns query result.
365      * This method is for executing an SQL query that returns result set.
366      * @param array $params input parameters (name=>value) for the SQL execution. This is an alternative
367      * to {@link bindParam} and {@link bindValue}. If you have multiple input parameters, passing
368      * them in this way can improve the performance. Note that if you pass parameters in this way,
369      * you cannot bind parameters or values using {@link bindParam} or {@link bindValue}, and vice versa.
370      * Please also note that all values are treated as strings in this case, if you need them to be handled as

Stack Trace

#2
+
 /var/www/happymoments.ua/web/protected/models/Seo.php(148): CActiveRecord->save()
143             $o_seo = Seo::model()->findByAttributes(['url' => $url]);
144             if (!$o_seo) {
145                 if($isCreate) {
146                     $o_seo = new Seo();
147                     $o_seo->url = $url;
148                     $o_seo->save();
149                     if ($isReturn) {
150                         return $o_seo;
151                     } else {
152                         return true;
153                     }
#3
+
 /var/www/happymoments.ua/web/protected/models/Seo.php(174): Seo::checkUrl()
169      * @return boolean
170      */
171     public static function implement($controller, $isCreate = false, array $default = null)
172     {
173         $url = parse_url(Yii::app()->request->url)['path'];
174         $o_seo = self::checkUrl($url, true, $isCreate);
175         
176         if($o_seo || $default) {
177             if(!empty($o_seo->title)) {
178                 $controller->pageTitle = $o_seo->title;
179             } else if(isset ($default['title'])) {
#4
+
 /var/www/happymoments.ua/web/protected/controllers/FaqController.php(56): Seo::implement()
51             $model = $this->loadModel($ids[0]);
52             $a_seo = [
53                 'title' => $model->question . ' - ' . Yii::t('faq', 'Справка по работе сервиса Happymoments.ua'),
54                 'description' => mb_substr($model->answer, 0, 180, 'utf8')
55             ];
56             Seo::Implement(false, $a_seo);
57 
58             $id = explode("-", $id);
59             $this->render('view', array(
60                 'model' => $model,
61             ));
2024-03-29 14:13:34 Apache/2.4.18 (Ubuntu) Yii Framework/1.1.17