1

我使用 Yii,我得到了这个错误;我应该理解和做什么?

不重复:来源或任何其他;

错误在:->bindParam(":url_id", $url->id)

$url = Url::model()->findByAttributes(array('link' => $_url));
        if (empty($url)) {
            $url = new Url();
            $url->website_id = $website->id;
            $url->link = $_url;
            $url->title = '';
            $url->description = '';
            $url->doctype = $_doctype;
            $url->visits = 1;
            $url->created = date('Y-m-d h:i:s',time());
            $url->updated = date('Y-m-d h:i:s',time());
            $url->status = 1;
            $url->save(false);
        } else {
            // update visits
            $url->saveCounters(array('visits' => 1));
            // url existed, let's load products
            if (!Yii::app()->user->isGuest) {
                $sql = "select u.id from url as u
                    left join url_follower as u_f
                    on u.id = u_f.url_id and u_f.user_id = :user_id
                    where u.id =:url_id";
                $cmd = Yii::app()->db->createCommand($sql)
                        ->bindParam(":url_id", $url->id)
                        ->bindParam(":user_id", Yii::app()->user->id);
                $url_id = $cmd->queryScalar();
4

1 回答 1

3

解决方案,测试:

$user_id = Yii::app()->user->id;
                $url_id = $url->id;
                $cmd = Yii::app()->db->createCommand($sql)
                        ->bindParam(":user_id", $user_id)
                        ->bindParam(":url_id", $url_id);
于 2013-02-08T22:46:29.793 回答