Skip to content

FlorianH/CI-RedBean-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Warning: This plugin contains an old version of redbeanphp.
I currently do not have the time to update it, sorry.

Codeigniter-RedBean-Plugin

This is a plugin that enables you to use the RedbeanPHP library in your Codeigniter projects. It is espacially usefull for database prototyping.

Redbean is available at: RedBeanPHP.com while CodeIgniter can be downloaded from CodeIgniter.com .

Installation

  1. Download this plugin and extract into your CI project (this will put two files into your /system/plugins folder.
  2. Enable the ci_redbean plugin by adding it to your autoloading config (/system/application/config/autoload.php line 66).
  3. Configure your database as you always do in CI.
  4. Create a model that extends the RedbeanModel class.

Usage

To use the new functionality, just create new instances of your models in your controller, add properties to them and call their save() method. The creation or alternation of the database tables aswell as the persistence will be completely handled by redbean. You will never have to touch your phpmyadmin again, because your model’s properties will be persisted, even if the models did not have a similar property before.

If you want to use this in production, you may want to freeze your database to prevent further changes and to enhance performance. To do that just add the following line to your database config file:

//system/application/config/database.php
$db['default']['frozen'] = TRUE;

Example

//system/application/models/Car_model.php
class Car_model extends RedbeanModel { }

//system/application/controllers/welcome.php
class Welcome extends Controller
{
  function index()
  {
    //Creates the table
    $car = new Car_model();
    $car->manufacturer = "Opel";
    $car->model = "Admiral";
    $car->save();
    
    //Transparently alters the existing table
    $car->tires = 4;
    $car->save();
  }
}

About

A ReadbeanPHP plugin for CodeIgniter

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages