2008年9月2日星期二

[fw-db] Re: Re[fw-db] lated tables reference error

humansky wrote:
>
> Hello all,
> I'm trying to setup a many-to-many relationship between "articles" and
> "keywords", but I keep getting the following error:
>
> Fatal error: Uncaught exception 'Zend_Db_Table_Exception' with message
> 'No reference from table ArticlesKeywords to table Keywords' in......
>

I just tried running your code and it works for me. Did you post exactly
the code you're running? Also, what version of PHP and Zend Framework are
you using? You should specify these things in any problem report.

Check for typos in your code. Also keep in mind that the comparison from
the value 'refTableClass'=>'Keywords' to the class name of Keywords is a
case-sensitive comparison. In other words, if the class name is 'Keywords',
then 'refTableClass'=>'keywords' will cause the error you report.

Here are a couple of other comments I'd like to make, but they're not
directly related to your original question:

$_dependentTables is used only for simulating cascading update and delete.
Since your ArticlesKeywords reference map doesn't mention any cascading
options, you don't need to define $_dependentTables in the two parent tables
at all. And even if you need cascading referential integrity, it's better
to do declare it in the database, as part of your foreign keys.

Your table articles_keywords doesn't need an id column. You should declare
the primary key over (article_id, keyword_id). Otherwise you have no way to
prevent associating a given article to a given keyword more than once.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Related-tables-reference-error-tp19270293p19274289.html
Sent from the Zend DB mailing list archive at Nabble.com.

没有评论: