CDbException

CDbCommand は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 tag_main_id= ORDER BY post_datetime desc LIMIT 5' at line 1. The SQL statement executed was: SELECT t.* FROM `tbl_voice` `t` WHERE post_datetime<now() and tag_l_id= and tag_main_id= ORDER BY post_datetime desc LIMIT 5

/home/mi/yii/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

#3
+
 /home/mi/protected/components/widgets/ListSameTagEntry.php(73): CActiveRecord->findAll(array("select" => array("t.*"), "limit" => 5, "condition" => "post_datetime<now() and tag_l_id= and tag_main_id=", "order" => "post_datetime desc"))
68                                           'select'    => array ( 't.*' ),
69                                           'limit'     => $this->count,
70                                           'condition' => implode(' and ', $cond),
71                                           'order'     => 'post_datetime desc',
72                                           );
73             $titles              = Voice::model()->findAll($condition);
74             foreach ($titles as $k=>$v) {
75                 $result[] = array('title'=>$v->medicine, 'url'=>Yii::app()->createUrl('voice/article', array('vid'=>$v->id)), 'post_datetime'=>$v->post_datetime);
76             }
77         }
78 //        print_r($result);exit;
#5
+
 /home/mi/protected/views/site/_right.php(54): CBaseController->widget("ListSameTagEntry", array("category_name" => "square", "tag_l_id" => null, "tag_main_id" => null, "count" => 5, ...))
49             }
50     $this->widget('ListSameTagEntry', array ( 'category_name' => $this->id,
51         'tag_l_id'      => $tag_l_id,
52         'tag_main_id'   => $tag_main_id,
53         'count'         => 5,
54         'more'          => true ));
55     ?>
56     <?php $this->widget('ListSameCategoryEntry', array ( 'category_id' => $model->entry_category_id, 'count' => 5, 'more' => true )); ?>
57 <?php endif; ?>
58 <div class="searchbox">
59 <?php
#9
+
 /home/mi/protected/views/square/article.php(83): CController->renderPartial("/site/_right", array("model_filter_right" => EntryFilterRight, "model" => Entry, "model_tag_l" => array(TagL, TagL, TagL, TagL, ...), "model_tag_main" => array(2 => array(TagMain, TagMain, TagMain, TagMain, ...), 3 => array(TagMain, TagMain, TagMain, TagMain), 4 => array(TagMain, TagMain, TagMain, TagMain), 5 => array(TagMain, TagMain, TagMain, TagMain, ...), ...)))
78 </div><!-- /#article_left -->
79 <?php if (isset($_POST['conf_voice']) && count($model_voice->getErrors())==0): ?>
80 <?php else: ?>
81 <div id="article_right">
82 <?php echo $this->renderpartial('/site/_login', isset($params)?compact('params'):''); ?>
83 <?php echo $this->renderpartial('/site/_right', compact('model_filter_right', 'model', 'model_tag_l', 'model_tag_main')); ?>
84 </div><!-- /#article_right -->
85 
86 <?php if (isset($params['conf']) && !$params['conf']): ?>
87 <p id="page_top"><a href="../header"><span class="invisible">PAGE TOP</span></a></p>
88 <?php endif; ?>
2024-03-19 19:18:11 Apache/2.2.14 (Unix) mod_ssl/2.2.14 OpenSSL/1.0.1u PHP/5.3.6 mod_perl/2.0.4 Perl/v5.8.8 Yii Framework/1.1.14