Search code examples
mysqljoinambiguousidiorm

an example of multiple column aliasing in idiorm


Using IDIORM and joining several tables - I dealt with one ambiguous column and the method meant that I need to select columns by name - this led to more ambiguous columns when I joined a third table. The method does not seem to chain for the alias I was using.

Is there anything beyond the documentation @readthedocs that could give examples of aliasing in idiorm over joining several tables? or several aliases in one query using idiorm

Help would be appreciated

http://idiorm.readthedocs.org/en/latest/ I also found has_many_through() on this link but am a little lost - https://github.com/j4mie/idiorm/pull/66

IDIORM

<?php     
    ...
    ->select_many(array('report_id' => REPORT_TABLE.'.id'),
                       ('address' => REPORT_TABLE.'.venue'),
                       ('event_date' => REPORT_TABLE.'.course_date'),
                  'name',
                  'username')
    ...

Solution

  • Firstly the PHP here doesn't look right.

    <?php
        ...
        ->select_many(array('report_id' => REPORT_TABLE.'.id'),
                           ('address' => REPORT_TABLE.'.venue'),
                           ('event_date' => REPORT_TABLE.'.course_date'),
        ...
    

    These should all be in the array. Like:

    <?php
        ...
        ->select_many(array('report_id' => REPORT_TABLE.'.id',
                            'address' => REPORT_TABLE.'.venue',
                            'event_date' => REPORT_TABLE.'.course_date'),
        ...