Code Monkey home page Code Monkey logo

lazy_loader's Introduction

/*
 * CakePHP Lazy Loader Plugin
 * Copyright (c) 2009 Matt Curry
 * http://www.pseudocoder.com/archives/2009/04/27/github-updates
 *
 * This is my second attempt at this.
 * The code posted by jose_zap (José Lorenzo - http://joselorenzo.com.ve/)
 * on bin.cakephp.org provided inspiration for this revised version
 * http://bin.cakephp.org/saved/39855
 *
 * @author      Matt Curry <[email protected]>
 * @license     MIT
 *
 */

/* Requirements */
PHP 5.1 or greater

/* Description */
The code is very beta.  Please give it a shot and let me know where you hit snags.  
I've tested it in basic app using Containable and it works great.  
It probably doesn't work with $recursive.

If you find a problem check out the unit tests and see if you can create a failing test case

/* Instructions */
1) Download the plugin to /app/plugins/lazy_loader

2) Put this either in your app_model.php or at the top of any model you want to use it:
   App::import('Model', 'LazyLoader.app_model');
   
3) Have your model extend LazyLoaderAppModel instead of AppModel
   class MyModel extends LazyLoaderAppModel {
   ...
   }
   
4) For this to work for HATBM relationships you need to include the joinTable and associationForeignKey in the defination.
   This is because Cake uses the associated models to set the defaults for these.  So even if you are following the conventions, set these to avoid having the related model loaded.
   class Post extends LazyLoaderAppModel {
	   var $name = 'Post';
     var $hasAndBelongsToMany = array('Tag' => array('joinTable' => 'posts_tags', 'associationForeignKey' => 'tag_id'));
   }

lazy_loader's People

Contributors

mcurry avatar lorenzo avatar

Watchers

James Cloos avatar Jeff Ripley avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.