GithubHelp home page GithubHelp logo

cakephp-metabehavior's Introduction

Coverage Status Build Status

CakePHP MetaBehavior

Join the chat at https://gitter.im/p0lym0rphik/cakephp-metabehavior

Introduction

CakePHP Metabehavior is a meta data Behavior for CakePHP 2. This behavior allows you to store, retrieve and search for metadata about any record for any model within your database.

Installation

  1. Add the folder on your app/Plugin directory.

  2. Make sure that the Plugin is loaded (check your bootstrap configuration).

  3. Run the following commands:

cd /path/to/installation/
app/Console/cake schema create MetaBehavior.metas
  1. Add the behavior to the model you want to use.
class MyModel extends Model {
	public $actsAs = array('Meta');
}

How to

  1. Add datas to an object.
// Just set meta key on the primary request model
	$savedDatas = $this->request->data;
	$savedDatas['MyModel']['foo'] = 'bar';
	
	$this->MyModel->save($savedDatas);
  1. Retrieve datas.
	// Just launch a find and datas are in the primary model.

	$model = $this->MyModel->findByid(1);
	
	return array(
		'MyModel' => array(
			'id' => 1,
			'foo' => 'bar'
		)
	)	
  1. You can directly search on meta values.
	$this->MyModel->find('all',array(
		'conditions' => array(
			'MyModel.foo =' => 'bar'
		)
	));

Licence GPL2

CakePHP MetaBehavior plugin Copyright (C) 2014 Fabien Moreau

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

cakephp-metabehavior's People

Contributors

p0lym0rphik avatar josegonzalez avatar gitter-badger avatar

Stargazers

 avatar

Watchers

 avatar

cakephp-metabehavior's Issues

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.