Development

Changeset 10101

You must first sign up to be able to contribute.

Changeset 10101

Show
Ignore:
Timestamp:
07/03/08 18:03:26 (2 months ago)
Author:
francois
Message:

sfPropelFinderPlugin Fixed problem when guessing relation on a table with a special phpName (based on a patch from mrhyde) (closes #3895)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfPropelFinderPlugin/README

    r10085 r10101  
    2121  where('Title', 'like', '%world')-> 
    2222  where('IsPublished', true)-> 
    23   order('ByCreatedAt')-> 
     23  orderBy('CreatedAt')-> 
    2424  with('Category')-> 
    2525  find(); 
  • plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php

    r10085 r10101  
    982982      if ($c->isForeignKey()) 
    983983      { 
    984         if(sfInflector::camelize($c->getRelatedTableName()) == $phpName) 
     984        try 
     985        { 
     986          $tableMap = $this->databaseMap->getTable($c->getRelatedTableName()); 
     987        } 
     988        catch (PropelException $e) 
     989        { 
     990          // So this table map hasn't been built yet, let's build it 
     991          $tmp = new $phpName(); 
     992          $relatedPeerClass = get_class($tmp->getPeer()); 
     993          $mapBuilder = call_user_func(array($relatedPeerClass, 'getMapBuilder'));  
     994          $mapBuilder->doBuild(); 
     995          $tableMap = $this->databaseMap->getTable($c->getRelatedTableName()); 
     996        } 
     997        if($tableMap->getPhpName() == $phpName) 
    985998        { 
    986999          return array( 
  • plugins/sfPropelFinderPlugin/test/unit/sfPropelFinderTest.php

    r10085 r10101  
    462462); 
    463463 
    464 $finder = sfPropelFinder::from('Article')->joinCategory()->where('Category_Name', 'foo')->_or('Category_Name', 'bar'); 
     464$finder = sfPropelFinder::from('Article')-> 
     465  joinCategory()-> 
     466  where('Category_Name', 'foo')-> 
     467  _or('Category_Name', 'bar'); 
    465468$finder->find(); 
    466469$t->is( 
     
    470473); 
    471474 
    472 $finder = sfPropelFinder::from('Comment') 
    473   ->joinArticle() 
    474   ->joinAuthor() 
    475   ->where('Article_Title', 'foo') 
    476   ->_or('Author_Name', 'bar'); 
     475$finder = sfPropelFinder::from('Comment')-> 
     476  joinArticle()-> 
     477  joinAuthor()-> 
     478  where('Article_Title', 'foo')-> 
     479  _or('Author_Name', 'bar'); 
    477480$finder->find(); 
    478481$t->is(