Kod
writing:
actAs:
Taggable: ~
Timestampable: ~
Sluggable:
fields: [title]
name: title_slug
canUpdate: true
unique: false
columns:
user_id:
type: integer
title:
type: string(255)
title_slug:
type: string(255)
content:
type: clob
relations:
User:
class: sfGuardUser
type: one
foreignType: many
foreignAlias: Writings
local: user_id
foreign: id
onDelete: CASCADE
options:
collate: utf8_unicode_ci
charset: utf8
indexes:
writings_index:
fields: [created_at, updated_at, title_slug]
actAs:
Taggable: ~
Timestampable: ~
Sluggable:
fields: [title]
name: title_slug
canUpdate: true
unique: false
columns:
user_id:
type: integer
title:
type: string(255)
title_slug:
type: string(255)
content:
type: clob
relations:
User:
class: sfGuardUser
type: one
foreignType: many
foreignAlias: Writings
local: user_id
foreign: id
onDelete: CASCADE
options:
collate: utf8_unicode_ci
charset: utf8
indexes:
writings_index:
fields: [created_at, updated_at, title_slug]
Jeden użytkownik może być autorem wielu tekstów, a jeden tekst posiada jednego użytkownika (autora). Próbuję "dobrać się" do wszystkich tekstów użytkownika nie za pomocą zwykłego getWriters() w sfGuardUser, ponieważ zależy mi na istnieniu dodatkowej kolumny - nazwy użytkownika. W tym celu dopisałem metodę w sfGuardPlugin:
class sfGuardUser extends PluginsfGuardUser { public function activation() { $this->setIsActive(1); $this->save(); return $this; } public function getWritingsWithUsername() { if($this->exists()) { return $this->getTable()->createQuery('u') //->setHydrationMode(Doctrine::HYDRATE_NONE) ->execute(); } return FALSE; } }
Niestety Doctrine zwraca mi zawsze tylko jeden rekord , pomimo że czysty SQL w konsoli PhpMyAdmin zwraca ich tyle, ile jest w bazie. Co ciekawe, jeśli wymuszę zachowanie na Doctrine::HYDRATE_NONE, to metoda użytkownika zwraca tyle rekordów co czysty SQL.
Czy ktoś wie dlaczego Doctrine zwraca tylko jeden rekord?