Od pewnego czasu męczę się z MySql, Doctrine i JOINLEFT. Mój plik schema.yml wygląda tak: (w zasadzie jest to kawałek tego pliku. Plik generuje przy pomocy WorkBench-a)
--- detect_relations: true options: collate: utf8_polish_ci charset: utf8 type: InnoDB User: tableName: Users COLUMNS: id: type: integer(4) PRIMARY: true notnull: true autoincrement: true username: type: string(45) notnull: true password: type: string(45) notnull: true email: type: string(45) notnull: true phone: type: string(100) notnull: true type: type: enum VALUES: ['u','a'] DEFAULT: 'u' active: type: integer(1) DEFAULT: 0 blocked: type: integer(1) DEFAULT: 0 options: charset: utf8 collate: utf8_polish_ci UsersDetail: tableName: UsersDetails COLUMNS: user_detail_id: type: integer(4) PRIMARY: true notnull: true autoincrement: true Users_id: type: integer(4) notnull: true name: type: string(45) surname: type: string(45) address: type: string(255) city: type: string(45) postcode: type: string(45) birthdate: type: string(45) relations: User: class: User LOCAL: Users_id FOREIGN: id foreignAlias: UsersDetails options: charset: utf8 collate: utf8_polish_ci
Natomiast moje zapytanie do bazy wygląda następująco:
$data = Doctrine_Query::create()->from('Model_User u')->select('u.*,d.*') ->leftJoin('u.Model_UsersDetail d ON d.Users_id=u.id') ->fetchArray();
Co robię źle, że wyrzuca mi taki błąd: Doctrine_Table_Exception: Unknown relation alias Model_UsersDetail??