sfAlyssaDoctrineObjectPathPlugin - 1.0.1

This plugin adds ObjectPath support to Doctrine.

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
Show source

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

  • Fixed documentation

2010-04-06 | 1.0.0

  • Initial import