sfAlyssaDoctrineObjectPathPlugin
1.0.1stable
for sf 1.4sf 1.3sf 1.2 and Doctrine
MIT
This plugin adds ObjectPath support to Doctrine.
This syntax makes it very easy to do sorting and filtering on foreign fields. ObjectPaths are dot-seperated relation-names that relate from one object to another and this behavior translates the objectPaths to table-aliasses.
This plugin is based on the work of Leon van der Ree and your plugin
sfPropelObjectPathBehaviorPlugin.
Developers
License
Copyright (c) 2010 - Cooperativa de Trabajo Alyssa Limitada
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
sfAlyssaDoctrineObjectPathPlugin plugin
Introduction
This plugin adds ObjectPath support to Doctrine.
This syntax makes it very easy to do sorting and filtering on foreign fields. ObjectPaths are dot-separated relation-names that relate from one object to another and this implementation translates the ObjectPaths to table-aliasses. The PropertyPaths are ObjectPaths with a field-name last element.
This plugin is based on the work of Leon van der Ree and your plugin
sfPropelObjectPathBehaviorPlugin.
Note: this plugin implement only a left join union. Other types are not supported yet.
Installation
1.Download and install the plugin
./symfony plugin:install sfAlyssaSmsPlugin
2.Clear the cache
./symfony cc
Example
So a very simple ObjectPath from City to Country is simply "Country" and from Country to City it would be "City":
In other words the relation-name.
However ObjectPaths support dots to 'jump' from object to object. Also you can use PropertyPaths, similar to ObjectPaths, to 'jump' from object to field.
So for example from Review to Book to Author the ObjectPath would be "Book.Author" and the PropertyPath would be "Book.Author.FirstName".
In Php-code this shows up as:
$query = Doctrine_Query::create();
$reviews = $query->
joinByObjectPath('Book.Author')->
orderByProperyPath('Book.Author.FirstName asc')->
excecute();
to find all reviews, left joined with their Books, left joined with their Authors.
There are some extra methods working with PropertyPaths:
$query = Doctrine_Query::create();
$reviews = $query->
joinByObjectPath('Book.Author')->
whereByProperyPath('Book.Author.FirstName = ?', 'Sergio')->
orderByPropertyPath('Book.Title')->
excecute();
similar to previous query, but filtering by FirstName property of Author and ordering by Title property of Book.
Note
The sfAlyssaDoctrineObjectPathPlugin is used in the sfDataSourcePlugin, but not required.
Todo
- Implement more join types.
Changelog
2010-04-10 | 1.0.1
2010-04-06 | 1.0.0