我正在关注此文档: http: //www.propelorm.org/documentation/04-relationships.html#manytomany_relationships
我有一个非常相似的设置(尽管为了便于阅读而进行了一些简化):
日志
<table name="logbook" phpName="Logbook" idMethod="native">
<column name="id" phpName="Id" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" autoIncrement="true" required="true"/>
<column name="location" phpName="Location" type="VARCHAR" size="255" required="false"/>
</table>
接触
<table name="contact" phpName="Contact" idMethod="native">
<column name="id" phpName="Id" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" autoIncrement="true" required="true"/>
<column name="title" phpName="Title" type="VARCHAR" size="255" required="true"/>
<column name="name" phpName="Name" type="VARCHAR" size="255" required="true"/>
<column name="telephone" phpName="Telephone" type="VARCHAR" size="20" required="true"/>
</table>
日志联系方式
<table name="logbook_contact" phpName="LogbookContact" idMethod="native" isCrossRef="true">
<column name="logbook_id" phpName="LogbookId" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
<column name="contact_id" phpName="ContactId" type="INTEGER" size="10" sqlType="int(10) unsigned" primaryKey="true" required="true"/>
<foreign-key foreignTable="contact" name="fk_logbook_contact_contact" onDelete="CASCADE" onUpdate="CASCADE">
<reference local="contact_id" foreign="id"/>
</foreign-key>
<foreign-key foreignTable="logbook" name="fk_logbook_contact_logbook" onDelete="CASCADE" onUpdate="CASCADE">
<reference local="logbook_id" foreign="id"/>
</foreign-key>
<index name="fk_logbook_contact_contact">
<index-column name="contact_id"/>
</index>
</table>
注意isCrossRef="true"
logbook_contact 表上的 ,它表明这是一个联结表。从这里我重新运行propel-gen om
,甚至propel-gen convert-conf
(在清除构建目录之后),但我似乎仍然无法做这样的事情:
<?php
/* presume $logbook has been LogbookQuery::create()'d already... */
$contacts = $logbook->getContacts();
$nbContacts = $logbook->countContacts();
我使用 Zend Studio,但在代码提示窗口中看不到它:
谁能向我建议我在这里可能做错了什么?我很高兴您向我指出文档 - 我已尽可能密切地关注这些文档,并且一切正常,直到$test
工作正常。