سلام استاد
من این کد زیر رو برا نمایش تعداد عکسهای برچسب گذاری شده نوشتم ولی خطا میده:
خطایی که میده اینه:
متشکرم.
من این کد زیر رو برا نمایش تعداد عکسهای برچسب گذاری شده نوشتم ولی خطا میده:
1 2 3 4 5 6 | $photoCount = Photos::model()->with( array ( 'tags' => array ( 'condition' => 'tags.id=:tagId' , 'params' => array ( ':tagId' => $tag ->id), ) ))-> count ( 't.confirmed=1' ); |
نقل قول:rules و relations جدول photos :خطای CDbCommand در اجرای SQL statement: SQLSTATE[42S22]: Column not found: 1054 Champ 't.confirmed' inconnu dans where clause. The SQL statement executed was: SELECT COUNT(DISTINCT `t`.`id`) FROM `photos` `t` LEFT OUTER JOIN `phototags` `tags_tags` ON (`t`.`id`=`tags_tags`.`photo_id`) LEFT OUTER JOIN `tags` `tags` ON (`tags`.`id`=`tags_tags`.`tag_id`) WHERE (t.confirmed=1) AND (tags.id=:tagId). Bound with :tagId='6' (C:wampYiiframeworkdbCDbCommand.php:543)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | public function rules() { return array ( array ( 'category_id, title, description' , 'required' ), array ( 'id, category_id, likes, dislikes, visits, confirm' , 'numerical' , 'integerOnly' =>true), array ( 'title' , 'length' , 'max' =>255), array ( 'likes, dislikes, visits, confirm' , 'safe' ) array ( 'id, category_id, title, description, likes, dislikes, visits, confirm' , 'safe' , 'on' => 'search' ), ); } public function relations() { return array ( 'category' => array (self::BELONGS_TO, 'Categories' , 'category_id' ), 'phototags' => array (self::HAS_MANY, 'Phototags' , 'photo_id' ), 'tags' => array (self::MANY_MANY, 'Tags' , 'phototags(photo_id, tag_id)' ), ); } |