За последние 24 часа нас посетили 19266 программистов и 1615 роботов. Сейчас ищут 933 программиста ...

symfony doctrine выборка из таблиц

Тема в разделе "PHP и базы данных", создана пользователем lina, 11 апр 2011.

  1. lina

    lina Активный пользователь

    С нами с:
    11 апр 2011
    Сообщения:
    1
    Симпатии:
    0
    Необходимо выбрать поля таблицы tab1 и поле sifr из таблицы tab2.Схема такая:
    config/doctrine/schema.yml
    ---
    Код (Text):
    1. bazaTab1:
    2. actAs:
    3. Timestampable: ~
    4. columns:
    5. date:
    6. type: date
    7. code_id:
    8. type: integer
    9. notnull: true
    10. ... .... .......
    11. relations:
    12. bazatab1:
    13. local: code_id
    14. foreign: id
    15. type: one
    16. foreignType: many
    17.  
    18. bazaTab2:
    19. actAs:
    20. Timestampable: ~
    21. columns:
    22. name:
    23. type: string(32)
    24. notnull: true
    25. shifr:
    26. type: int(4)
    27. notnull: true
    28. <HTML>
    1) В методе setup() класса BasebazaTab1.class.php:
    HTML
    Код (Text):
    1. public function setUp()
    2. {
    3. parent::setUp();
    4. $this->hasOne('bazaTab2', array(
    5. 'local' => 'code_id',
    6. 'foreign' => 'id'));[/B]$timestampable0 = new Doctrine_Template_Timestampable();
    7. $this->actAs($timestampable0);
    8. }
    9.  
    2) В методе setup() класса BasebazaTab2.class.php:
    Код (Text):
    1.  
    2. public function setUp()
    3. {
    4. parent::setUp();
    5. $this->hasMany('bazaTab1', array(
    6. 'local' => 'id',
    7. 'foreign' => 'code_id'));
    8.  
    9. $timestampable0 = new Doctrine_Template_Timestampable();
    10. $this->actAs($timestampable0);
    11. }
    Сам запрос на симфони:
    Код (Text):
    1. $q = Doctrine_Query::create()
    2.   ->from('bazaTab1 o, o.bazaTab2 o2')
    3.   ->where('o.code_id=?','o2.id')
    4.   ->Andwhere('o.date = ?', '2010-12-22') ;
    5. $this->result=$q->execute();
    выдает данные только из 1-й таблицы Tab1.
    в ЧЕМ ДЕЛО?