Skip to content
CakePHP plugin - Easily create joins for your associated models
PHP
Find file
Pull request Compare This branch is 1 commit behind tigrang:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Model
.gitignore
README.md
composer.json

README.md

EasyJoin

CakePHP plugin - Easily create joins for your associated models.

EasyJoin makes using ad-hoc joins simple and quick. No longer do you have to deal with unbinding/bindings model on-the-fly or writing join arrays to force Cake to use joins instead of doing multiple queries. EasyJoin will automatically detect the relationship between model and create joins array for you.

Requirments

  • PHP >= 5.3.0
  • CakePHP >= 2.0

Installation

[Manual]

  1. Download this: http://github.com/tigrang/EasyJoin/zipball/master.
  2. Unzip
  3. Copy the resulting folder to app/Plugin
  4. Rename the folder to EasyJoin

[GIT Submodule]

In your app directory run:

git submodule add https://github.com/tigrang/EasyJoin.git Plugin/EasyJoin
git submodule init
git submodule update

[GIT Clone]

In your plugin directory run:

git clone https://github.com/tigrang/EasyJoin.git

Usage

AppModel

App::uses('EasyJoinAppModel', 'EasyJoin.Model');
class AppModel extends EasyJoinAppModel {
}

Example

public function findBySubscriber($id) {
    App::uses('Course', 'Model');
    return $this->find('all', array(
        'conditions' => array('Subscription.subscriber_id' => $id),
        'joins' => array(
            self::joinLeft('Subscription'),
            self::joinLeft('Course'),
            self::joinLeft('Professor'),
            Course::joinLeft('Department'),
            Course::joinLeft('Client'),
        ),
    ));
}

Credits

EasyJoin was inspired by the article "Restoring elegance to CakePHP — doing multiple joins The Right Way™"

Something went wrong with that request. Please try again.