вопрос на засыпку

Всем привет,

до давних пор я программировал на PHP Prado Framework.

Хотел бы научится Yii framework, взял вот такую вот книгу на обучение Agile Web Application Development with Yii 1.1 and PHP5 и смотрю, что yii на много сложнее чем prado. Ребята как мне быстрее научится yii после того как пробывал prado framework ? :rolleyes:

застрял на одной части и не могу разобраться в чём проблема :(

На чем застряли?

CDbException

Description

The relation "users" in active record class "Project" is specified with an invalid foreign key. The format of the foreign key must be "joinTable(fk1,fk2,…)".

Source File

/var/www/trackstar/protected/models/Project.php(106)

00094: $criteria->compare(‘update_user_id’, $this->update_user_id);

00095:

00096: return new CActiveDataProvider(get_class($this), array(

00097: ‘criteria’ => $criteria,

00098: ));

00099: }

00100:

00101: /**

00102: * @return array of valid users for this project, indexed by user IDs

00103: */

00104:

00105: public function getUserOptions() {

00106: $usersArray = CHtml::listData($this->users, ‘id’, ‘username’);

00107:

00108: return $usersArray;

00109: }

00110:

00111: }

00112:

00113: ?>

сам релейшен и опсиание таблиц в студию




CREATE TABLE IF NOT EXISTS `tbl_issue` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(256) NOT NULL,

  `description` varchar(2000) DEFAULT NULL,

  `project_id` int(11) DEFAULT NULL,

  `type_id` int(11) DEFAULT NULL,

  `status_id` int(11) DEFAULT NULL,

  `owner_id` int(11) DEFAULT NULL,

  `requester_id` int(11) DEFAULT NULL,

  `create_time` datetime DEFAULT NULL,

  `create_user_id` int(11) DEFAULT NULL,

  `update_time` datetime DEFAULT NULL,

  `update_user_id` int(11) DEFAULT NULL,

  PRIMARY KEY (`id`),

  KEY `FK_issue_project` (`project_id`),

  KEY `FK_issue_owner` (`owner_id`),

  KEY `FK_issue_requester` (`requester_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;






CREATE TABLE IF NOT EXISTS `tbl_project` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `name` varchar(128) DEFAULT NULL,

  `description` text,

  `create_time` datetime DEFAULT NULL,

  `create_user_id` int(11) DEFAULT NULL,

  `update_time` datetime DEFAULT NULL,

  `update_user_id` int(11) DEFAULT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;






CREATE TABLE IF NOT EXISTS `tbl_project_user_assignment` (

  `project_id` int(11) NOT NULL,

  `user_id` int(11) NOT NULL,

  `create_time` datetime DEFAULT NULL,

  `create_user_id` int(11) DEFAULT NULL,

  `update_time` datetime DEFAULT NULL,

  `update_user_id` int(11) DEFAULT NULL,

  PRIMARY KEY (`project_id`,`user_id`),

  KEY `FK_user_

project` (`user_id`)

) ENGINE=InnoDB DEFAULT CHARSET=latin1;






CREATE TABLE IF NOT EXISTS `tbl_user` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `email` varchar(256) NOT NULL,

  `username` varchar(256) DEFAULT NULL,

  `password` varchar(256) DEFAULT NULL,

  `last_login_time` datetime DEFAULT NULL,

  `create_time` datetime DEFAULT NULL,

  `create_user_id` int(11) DEFAULT NULL,

  `update_time` datetime DEFAULT NULL,

  `update_user_id` int(11) DEFAULT NULL,

  PRIMARY KEY (`id`)

) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;






User.php


public function relations()

	{

		// NOTE: you may need to adjust the relation name and the related

		// class name for the relations automatically generated below.

		return array(

			'tblIssues' => array(self::HAS_MANY, 'TblIssue', 'owner_id'),

			'tblProjects' => array(self::MANY_MANY, 'TblProject', 'tbl_project_user_assignment(user_id, project_id)'),

		);

	}






Project.php

public function relations() {

        // NOTE: you may need to adjust the relation name and the related

        // class name for the relations automatically generated below.

        return array(

            'issues' => array(self::HAS_MANY, 'Issue', 'project_id'),

            'users' => array(self::MANY_MANY, 'User', 'tbpl_project_user_assignment(project_id, user_id'),

        );

    }

}






Issue.php

public function relations() {

        // NOTE: you may need to adjust the relation name and the related

        // class name for the relations automatically generated below.

        return array(

            'requester' => array(self::BELONGS_TO, 'User', 'requester_id'),

            'owner' => array(self::BELONGS_TO, 'User', 'owner_id'),

            'project' => array(self::BELONGS_TO, 'Project', 'project_id'),

            'requester' => array(self::BELONGS_TO, 'User', 'requester_id'),

        );

    }



попробуйте исправить

user_di на user_id

нет это не помогает :(

еще

tbpl_project_user_assignment, приведеная таблица tbl_project_user_assignment

хмм поправил, но эффекта тоже нету




The relation "users" in active record class "Project" is specified with an invalid foreign key. The format of the foreign key must be "joinTable(fk1,fk2,...)".



а еще, если внимательно вглядеться то значение получается tbpl_project_user_assignment(project_id, user_di

не хватает закрывающей скобки.

это не относится к делу, если бы была проблема в скобке я бы здесь помойму не писал бы ничего, а нашёл бы сам где скобки нету

а проблема именно в ней, код из фреймворка:


if(!preg_match('/^\s*(.*?)\((.*)\)\s*$/',$this->relation->foreignKey,$matches))

	throw new CDbException(Yii::t('yii','The relation "{relation}" in active record class "{class}" is specified with an invalid foreign key. The format of the foreign key must be "joinTable(fk1,fk2,...)".',

		array('{class}'=>get_class($parent->model),'{relation}'=>$this->relation->name)));