Table aliasing with the new ->join
Table aliasing with the new ->join
helmm
Posts: 3Questions: 0Answers: 0
I've been doodling with the new ->join functionality in Editor 1.2 and I have not been able to figure out how to get an alias to take. I thought it would be the name option but that has not done it so far. I have a table of publishers with (idPublisher, Publisher, Publisher_Parent) the publisher parent contains a idPublisher number for grouping purposes. Instead of the # showing in the table I wanted to show the actual name using a query similar to the following.
[code]SELECT p2.Publisher
FROM publisher as p2
JOIN publisher` on (publisher.idPublisher = p2.idPublisher)[/code]
This is the last editor::inst that I used.
[code]
$editor = Editor::inst( $db, 'publisher', 'idPublisher' )
->field(
Field::inst( 'Publisher' )->validator( 'Validate::required' ),
Field::inst( 'Publisher_Parent' ),
Field::inst( 'Publisher_Code' )
)
->join(
Join::inst( 'publisher', 'object')
->name('p2')
->join( 'idPublisher', 'idPublisher' )
->field( Field::inst( 'Publisher' )
)
);
[/code]
Any input would be appreciated.
[code]SELECT p2.Publisher
FROM publisher as p2
JOIN publisher` on (publisher.idPublisher = p2.idPublisher)[/code]
This is the last editor::inst that I used.
[code]
$editor = Editor::inst( $db, 'publisher', 'idPublisher' )
->field(
Field::inst( 'Publisher' )->validator( 'Validate::required' ),
Field::inst( 'Publisher_Parent' ),
Field::inst( 'Publisher_Code' )
)
->join(
Join::inst( 'publisher', 'object')
->name('p2')
->join( 'idPublisher', 'idPublisher' )
->field( Field::inst( 'Publisher' )
)
);
[/code]
Any input would be appreciated.
This discussion has been closed.
Replies
I have this marked down as a feature to be implemented for the next update - sorry I don't have an immediate solution for you.
The best suggestion I can make at the moment is a read-only one - don't use `Join` but rather when 'getting' data, loop over the data that is retrieved and for each query the database (or used a cached query result) and assign the extra information to the data rows. But as I say, that would only work for read only - write as well would require a custom controller to be written.
Regards,
Allan
Regards,
Allan
Regards,
Allan