これには簡単な答えが必要なことはわかっていますが、理解できません。涙を流した後、ここの誰かが助けてくれることを願っています。
これが私のYMLモデルです。
Identity:
columns:
id:
type: integer(10)
primary: true
autoincrement: true
username:
type: string(255)
Profile:
columns:
id:
type: integer(10)
primary: true
autoincrement: true
identity_id:
type: integer(10)
profiletype_id:
type: integer(10)
name:
type: string(255)
relations:
Identity:
local: identity_id
foreign: id
class: Identity
foreignAlias: Profiles
Profiletype:
local: profiletype_id
foreign: id
class: Profiletype
foreignAlias: Profiles
Profiletype:
columns:
id:
type: integer(10)
primary: true
autoincrement: true
type:
type: string(255)
ご覧のとおり、3つのリンクされたテーブルが生成されます。
ID-
複数のプロファイルを持つことができます
プロファイル-1
つのID
を持ちます-1つのプロファイルタイプを持ちます
プロファイルタイプ
-複数のプロファイルを持つことができます
これで、私のコードでは、IdentityとProfiletypeの生成されたモデルに対してクエリを実行できます。
例えば:
$q = Doctrine_Query::create()
->select('i.*')
->from('Identity i');
echo $q->getSqlQuery();
動作し、生成されます:
SELECT i.id AS i__id, i.username AS i__username FROM identity i
ただし、プロファイルテーブルでクエリを実行しようとすると、機能しません。次のような単純なクエリでも
$q = Doctrine_Query::create()
->select('p.*')
->from('Profile p');
echo $q->getSqlQuery();
失敗します。FROMのクラス名を「Profile」ではなく「Profiles」に変更してみました。まだ何もありません。
私が間違っていることについてのアイデア。