Version 11, last updated by m4rw3r at Sep 02 05:24 2008 UTC
IgnitedRecord Manual
This manual is outdated! A new one will soon be up!
In the meantime you can check the manual by downloading IgnitedRecord here.
This manual is for 0.1.1 .
Table of Contents:
IgnitedRecord Model
This is an ActiveRecord-like (Ruby's ActiveRecord) ORM model which is aimed to be simple to use, yet very customizable.
Every derived class is a factory which produces objects which in turn represents a row in the database table which the derived class is mapped to.
Installation
Drop the folder ignitedrecord in your application/models directory.
IgnitedRecord uses the CodeIgniter ActiveRecord implementation, so the $active_record option must be set to true in the application/config/database.php.
The MY_Loader.php file is optional, but provides a custom loader function which simplifies the loading of IgnitedRecord and its derived classes.
This file should be put in the application/libraries folder. If you already have a custom loader file (or use another loader class, eg. Matchbox), copy the ORM you also have to install a yamlparser.
yamlfactory() uses a yaml parser called YAYparser, it is bundled with IgnitedRecord, but you can easily edit yamlfactory() to utilize another parser.
To install YAYparser, copy yayparser_helper.php from the helpers dir to your application/helpers
PHP 4
If you are using PHP 4, the two __call() methods won't work. The __call() methods only provides an aggregation of the helpers and behaviours, which is not necessary, but it makes for a bit shorter code.
Example:
$children = $rec->get_children(); // use the IgnitedRecord tree behaviour, with help from __call()
$children = $rec->tree->get_children(); // same result, this time without __call()
$node = $this->page->xpath('/about/me'); // use the IgnitedRecord tree behaviour's xpath() method, with help from __call()
$node = $this->page->tree->xpath('/about/MPTtree'); // same as above, without call()
Another thing you might want to do is to replace all '= new' with '=& new' (8 places in the IgnitedRecord class).
Extend The IgnitedRecord Model
This model is meant to be extended by child classes, and is not to be used directly. Therefore you have to let other classes extend the IgnitedRecord class.
Because the models inherit each other, you have to load them in order. The Model class must be loaded before the IgnitedRecord class which in turn must be loaded before the derived classes.
The easiest way is to call $this->load->model('ignitedrecord/ignitedrecord') in the controller, before you load any of the derived classes.
There is also a custom MY_Loader.php which simplifies the loading of derived classes.
It provides this method:
orm('modelname' = false, name = '', db_conn = FALSE)
If modelname is not set (is false), orm() will not call Loader::model(). It will only load the Model class and IgnitedRecord class, but will not instantiate them.
But if modelname is set, after it has loaded the Model class and IgnitedRecord, orm() will call Loader::model() and pass all recieved parameters to it (well, modelname, name and db_conn).
So the orm() method can act like a wrapper for the Loader::model().
Example:
$this->load->orm();$this->page = IgnitedRecord::factory('page');
// or:
$this->load->orm('page'); // calls $this->load->model('page')
Derived classes
The most simple model you can have with IgnitedRecord is the following:
class Page extends IgnitedRecord{function Page(){
parent::IgnitedRecord();
}
}
This model maps itself to the Pages table in the database and contains all basic methods for fetching data from the database.
See Methods for fetching data for more information on how to fetch data using the inherited methods.
In the child classes you can specify a lot of different options, if an option is not specified a default value is assumed:
| Property | Default | Description |
|---|---|---|
| $table | Pluralized version of class name ( minus 'model', if exists) | The table this model is mapped to |
| $id_col | id | The column that stores the unique id, preferred to be auto incremental unsigned int |
| $columns | autoloaded when needed | Contains all column names, define yourself to save one query (SHOW COLUMNS FROM…) |
| $child_class | IgnitedRecord_record | The name of the class which this factory produces |
| $auto_load_relationships | false | If to autoload the relations when an object is created (Warning, can cause endless loops because of a related table having $auto_load_relationships switched on and relates back to this table) |
| $act_as | array() | The behaviours this model shall utilize, read more about Behaviours |
| $belongs_to | null | Specifies the attributes of one or more Belongs To relationships that this model has |
| $has_many | null | Specifies the attributes of one or more Has Many relationships that this model has |
| $has_one | null | Specifies the attributes of one or more Has One relationships that this model has |
| $has_and_belongs_to_many | null | Specifies the attributes of one or more Has And Belongs To Many relationships that this model has |
| $habtm | null | An alias for $has_and_belongs_to_many. These two arrays will be merged to one in the constructor. |
There are also a second way of creating a derived class: The factory() and yamlfactory() methods:
factory('table name', settings = array())
This method creates and instantiates a derived class linked to the table table name and with the properties stored in the settings array (property => value).
The instantiated object is returned.
Note: All propertynames is prepended with a double underscore.
yamlfactory('filename')
A factory that utilizes yaml instead of a PHP array.
If the filename is a yaml string (contains \n) it is parsed with yayparser into a PHP array. This array is then passed to a new IgnitedRecord object.
If the filename is a filename (does not contain \n), IgnitedRecord attempts to load the file, then parses it into a PHP array.
Note: All propertynames is prepended with a double underscore.
Establish Relations
To define a relationship between two tables, you can use two approaches:
You have to set one of these properties:
- $belongs_to
- $has_many
- $has_one
- $has_and_belongs_to_many
Or you can use one of these methods (they accept the same data as the properties, but can only add/replace relations):
- set_belongs_to()
- set_has_many()
- set_has_one()
- set_habtm() (Has And Belongs To Many)
The simplest value these properties can contain is the table name of the related table.
But there are more settings that can be altered and specified through these properties. The settings and their default values vary, so check the part of the manual that is covering the specific relation type.
The properties can be specified in four ways:
// single:= 'tablename';
// multiple:
= array('tablename','tablename');
// the advanced variant (enables to override defaults):
= array('name' => 'relationname',
'table' => 'tablename', // all others except this one can be omitted
'col' => 'foreign_key_col',
'model' => 'modelname'
);
// multiple w. advanced variant:
= array(array('name' => 'relationname',
'table' => 'tablename',
'col' => 'foreign_key_col',
'model' => 'modelname'
),
array('table' => 'anothertable'),
'atable' // simple, preferred to the one above (shorter :P)
);
Example:
var $belongs_to = array('users','forums'); // relate to two tablesvar $has_many = array('table' => 'posts', 'col' => 'post_id'); // override the default foreign key column name (posts_id)
var $has_and_belongs_to_many = array(array('table' => 'tags', 'rel_table' => 'tagged'),
'moderators'); // multiple relations + overrride
// in controller example:
$this->teacher->set_has_many('students');
There are four types of relations which IgnitedRecord supports:
Belongs To
The Belongs To relationship is often used at the receiving end of a Has Many or a Has One relationship.
Example:
| class user extends IgnitedRecord{ var $has_one = ‘pictures’; function user(){ parent::IgnitedRecord(); } } class picture extends IgnitedRecord{ var $belongs_to = 'users'; function picture(){ parent::IgnitedRecord(); } } | |
Here we have specified a relation between the users table and the pictures table.
The pictures Belongs To users, and therefore pictures table has a foreign key column (the key referring to the other table) referring to users (called usersid).
The difference between a Belongs To and a Has One is that Belongs To has the foreign key in the table which Belongs To, while the Has One stores the key in the related table.
To specify special settings in a relationship, define an array containing the settings you want to override (would replace the normal position of the table name).
The default settings for the Belongs To relation is the following:
| Key | Default | Description |
|---|---|---|
| table | REQUIRED | The related table |
| name | modelname (of the related table) or singular(tablename) | The relation name, used when adding, removing and loading related records |
| model | tablename or singular(tablename), depending on if a model with that name exists | The model to be used when instantiating related records (if no model is found, it uses this class to instantiate the records) |
| col | tablename of the related table + id | The foreign key column used by the relation |
Has Many
This relation type describes a one to many relationship.
Example:
A user can have many posts:
Here Foo Bar has two posts, and Another Person has one post. The posts still belong to only one user, however.
Code for establishing this relation:
class user extends IgnitedRecord{var $has_many = 'posts';
function user(){
parent::IgnitedRecord();
}
} class post extends IgnitedRecord{
var $_belongs_to = 'users';
function post(){
parent::IgnitedRecord();
}
}
Settings for a Has Many relationship:
| Key | Default | Description |
|---|---|---|
| table | REQUIRED | The related table |
| name | the tablename of the related table | The relation name, used when adding, removing and loading related records |
| model | tablename or singular(relatedtablename), depending on if a model with that name exists | The model to be used when instantiating related records (if no model is found, it uses this class to instantiate the records) |
| col | tablename of this table + id | The foreign key column used by the relation |
one">Has One
This is like an inverted Belongs To relation, both relates one to one. But by specifying a Has relationship, we declare that the foreign key (the key referring to the other table) should reside in the other table. In the case in the Belongs To paragraph, pictures.
Or you can look at it as a Has Many relation, but with the limitation that only one related record is allowed.
Settings for a Has One relationship:
| Key | Default | Description |
|---|---|---|
| table | REQUIRED | The related table |
| name | modelname (of the related table) or singular(relatedtablename) | The relation name, used when adding, removing and loading related records |
| model | tablename or singular(tablename), depending on if a model with that name exists | The model to be used when instantiating related records (if no model is found, it uses this class to instantiate the records) |
| col | tablename of this table + id | The foreign key column used by the relation |
Has And Belongs To Many
This is the relation you choose when you need to have many to many relations. For example a developer can have (or belong to) many clients, but a client can have (or belong to) many developers.
Example table diagram:
class person extends IgnitedRecord{var $table = 'people'; // override the default value: persons
var $has_and_belongs_to_many = 'pictures';
function person(){
parent::IgnitedRecord();
}
} class picture extends IgnitedRecord{
var $has_and_belongs_to_many = array('table' => 'people', 'model' => 'person'); // set a model
function picture(){
parent::IgnitedRecord();
}
}
Example of data inserted and with relations in both ways:
Here the Another Person relates to both img1 and img3, while img2 relates to both Foo Bar and Some Dude.
Example returns when calling get_related():
$pictures = $rec->get_related('pictures');
echo "Pictures containing {$rec->firstname}";
foreach($pictures as $pic){
echo '<img src="'.$pic->path.'/>'; // insert image
// echo those other people on the picture
foreach($pic->get_related('people') as $person){
echo $person->firstname;
}
}
Settings, their default values and their keynames:
| Key | Default | Description |
|---|---|---|
| table | REQUIRED | The related table |
| name | the related tablename | The relation name, used when adding, removing and loading related records |
| model | tablename or singular(relatedtablename), depending on if a model with that name exists | The model to be used when instantiating related records (if no model is found, it uses this class to instantiate the records) |
| rel_table | 'thistablename_relatedtablename' or 'relatedtablename_thistablename', depending on which one comes first alphabetically | The table used for storing the relations |
| thiscol | tablename + id | The foreign key column used relating to this table |
| othercol | tablename of the related table + id | The foreign key column used relating to the related table |
Methods for fetching data
All these methods return IgnitedRecord_records, see The IgnitedRecord_record object for information on how to obtain and manipulate data from them.
If the $child_class property is changed, the objects created will be of that type.
find(id)
The find() method returns the record with the supplied id id.
Returns false if nothing was found.
get()
This method fetches one record from the table. It is meant to be used in conjunction with CodeIgniter's ActiveRecord class, where the ActiveRecord class filters and sorts the query (you can see it as a replacement for the Active Record's get() method).
The only call to the db this method does is the following (to fetch the row from the mapped table):
$data = $this->db->get($this->table,1);, see the CodeIgniter ActiveRecord manual for details.
$record = $this->page->get();
find_by(column(s), data)
Returns the first record where the data in the column(s) column(s) matches data.
The column(s) parameter can be array or scalar, the same for data. These two arrays are then merged into an array, where the elements in the column(s) array is the keys and the elements in the data array are values. This array are then sent to CodeIgniter's ActiveRecord library, so the column(s) can contain !=, >, <, etc.
Example:
$record = $this->page->find_by('title','index'); // searches for a record with the title 'index'$record = $this->page->find_by(array('id >','title'),array(3,'blog')); // searches for a record where the id is greater than 3 and the title equals 'blog'
find_by_sql('sql_query_string')
Returns a record (the first one, so limit the query to return one row to lower bandwith usage) created from the data returned from the query sql_query_string. The query should be escaped and should start with 'SELECT * ' or equivalent.
Example:
$record = $this->page->find_by_sql('SELECT , count() AS Authors FROM pages WHERE Authors > 2 LIMIT 1');// this will also create a column named Authors, which will be ignored when you save the $record
find_all()
Returns all records in the table.
Or, it could be used as a substitute for CodeIgniter's ActiveRecord db::get() method. The only call to the db this method does is the following (to fetch all rows from the mapped table):
$data = $this->db->get($this->table);, see the CodeIgniter ActiveRecord manual for details.
The difference is that find_all() returns all rows, get() returns only one.
find_all_by(column(s), data)
As find_by(), but returns all matching records.
find_all_by_sql('sql_query_string')
As find_by_sql(), but returns all matching records.
new_record(data = array())
Returns a new IgnitedRecord_record which isn't linked to a db row. Populates it with the associative array data.
To enter the record in the database after the creation, use the save() method.
The IgnitedRecord_record object
This is the object that stores the individual row data. It is linked to the IgnitedRecord model (or rather the derived class) which it uses for saving, updating, relations, etc.
The properties of the IgnitedRecord_record are the column values of the record.
Example:
foreach($records as $record){
echo "{$record->title}\n";
}
The methods available in the IgnitedRecord_record class are these:
save(force = false)
This method saves the record to the database. If the record does not exist in the database (the id is set to null (default)), an insert is performed.
Empty objects cannot be inserted (because CodeIgniter does not allow inserts without data).
If force is true, the object will be saved even if it was unchanged.
$rec = $this->page->new_record();$rec->title = 'test';
$rec->save(); // performs an insert of a row with the title value set to 'test'
$rec = $this->page->find_by('title','About');
$rec->title = 'Me';
$rec->save(); // performs an update of the row fetched by find_by()
If the INSERT/UPDATE is successful, true is returned, otherwise is false returned.
If the data in the record has not been altered, save() will not save the data again (and false is returned).
update()
Updates the data in the current object. If the row has been deleted from the database, the object still contains the data (but the id is removed, so it isn't linked to a record).
in_db()
Returns true if this object is linked to a row in the database.
$rec = $this->page->find(3);var_dump($rec->in_db()); // TRUE
$rec = $this->page->new_record();
var_dump($rec->in_db()); // FALSE
uid()
Returns the unique id of the current record (the value of the id column(s)).
If this record does not exist in the database, false is returned.
echo "<li><a href='".site_url('thiscontroller','view',$page->uid())."'>".$page->title"</a></li>";
}
delete()
Deletes the record from the database. All data (except relations and id) in the record are preserved, so you can save it again or use the data in any other way.
load_rel('name' = false)
Loads the related records of this object. The name specifies a certain relation to load relations for. If the name parameter is omitted, all relations will be loaded.
The relations will be stored in the property with the name of the relation if it is not set (not used). Otherwise you can fetch the related objects using get_related().
$record->load_rel();print_r($record); // OK, this prints a lot, use a special version of print_r that omits the IgnitedRecord object among others
// Result:
// IgnitedRecord_record Object (
// …
// [title] => 'Index',
// [data] => IgnitedRecord_record Object (
// …
// [contents] => 'Here is the contents of the page'
// )
// )
load_related('name' = false)
Loads the related records for the relation with the name name. Alias for load_rel().
get_related('name')
Returns the related records from the relation with the name name. Depending on if it is a Belongs To, Has Many, Has One or Has And Belongs To Many, the result can be an array or an IgnitedRecord_record. If the relation is not loaded, it will be loaded.
If no related object(s) are found, false will be returned.
add_relaionship(record, 'relation_name' = false)
This method establishes a relationship between this IgnitedRecord_record and the supplied record. The relationship_name is the name of the desired relationship to use, if omitted IgnitedRecord will try to figure it out.
Depending on the settings of the IgnitedRecord instance tied to this object, the type of relation can vary.
Ex. If you have defined two relations, one to "posts" with Has Many and one to "moderators" with Has And Belongs To Many, and you pass an object of the type "posts", a Has Many relation will be established.
If no relation is established with this record's table and record's table in the Ignitedrecord instance (the model attached to this record), no relation will be formed.
add('relation_name', record)
Somewhat of a shorthand for add_relationship, but requires the relationship name.
$obj->add('child',$object);remove_relationship(record, 'relation_name' = false)
If a relation has been established between this record and record, it will be removed. The relation_name is the name of the specific relation to remove, if omitted IgnitedRecord will try to figure it out. If no relation is defined (in the model attached to this record) or established betwen the two records, nothing is done.
remove('relation_name', record)
Shorthand for remove_relationship(), but requires the relationship name.
Behaviours
Coming soon
I haven't made this section yet, but if you want to check out on how to make a behaviour, look at $act_as, $_child_class_helpers and load_behaviours() in IgnitedRecord.
An example is the bundled IgnitedRecord_tree behaviour.
Hooks
The hooks are places where you can add your own code to execute between different parts of IgnitedRecord.
Trigger is maybe a more fitting description, but you have a hook and you attach your code to the hook (sort of hanging your code there and then when the hook is called, the code on the hook will be called :P ).
To add some code to a hook you first have to place the code in a separate function/method which you then can add to the hook.
The second step is to register your function with the help of the add_hook() method:
add_hook('hook_name', 'function_name', priority = 10)
Method variant:
add_hook('hook_name', array(object, 'method_name'), priority = 10)
The higher the priority number, the lower priority the hooked code will have. The hooked code will be run in order with the lowest priority number first (and if two hooks have the same priority, the one added first will be run first).
Example:
function add_prop(&$object){ // the ampersand is important, it is required for the reference to work (at least for scalars, depending on PHP version)$object->added_prop = 'We have added this!';
}
$this->page->add_hook('post_get',array($this,'add_prop'));
$rec = $this->page->get();
echo $rec->added_prop; // will echo "We have added this!"
Here are the hooks, their names, arguments and description:
| Hook | Arguments | Description |
|---|---|---|
| pre_get | This hook is run before the get() method does anything | |
| post_get |
| This hook is run after the get() method has fetched and instantiated data |
| pre_find |
| This hook is run before the find() method does anything |
| post_find |
| This hook is run after the find() method has fetched and instantiated data |
| pre_find_by |
| This hook is run before the find_by() method does anything |
| post_find_by |
| This hook is run after the find_by() method has fetched and instantiated data |
| pre_find_by_sql |
| This hook is run before the find_by_sql() method does anything |
| post_find_by_sql |
| This hook is run after the find_by_sql() method has fetched and instantiated data |
| pre_find_all | This hook is run before the find_all() method does anything | |
| post_find_all |
| This hook is run after the find_all() method has fetched and instantiated data |
| pre_find_all_by |
| This hook is run before the find_all_by() method does anything |
| post_find_all_by |
| This hook is run after the find_all_by() method has fetched and instantiated data |
| pre_find_all_by_sql |
| This hook is run before the find_all_by_sql() method does anything |
| post_find_all_by_sql |
| This hook is run after the find_all_by_sql() method has fetched and instantiated data |
| post_new_record |
| This hook is run after the new_record() method has instantiated data |
| save_pre_stripdata |
| This hook is run before the strip_data() method has returned a clean array |
| save_post_stripdata |
| This hook is run after the strip_data() method has returned a clean array |
| save_pre_insert |
| This hook is run before the save() method has called db::insert() |
| save_post_insert |
| This hook is run after the db::insert() has inserted the clean data array |
| save_pre_update |
| This hook is run before the save() method has called db::update() |
| save_post_update |
| This hook is run after the db::update() has saved the clean data array |
| save_abort |
| This hook is run if the save() method detect that the object is unchanged or empty and aborts |
| post_save |
| This hook is run after the save() method has saved the clean data array |
| pre_update |
| This hook is run before the update() has created the new refreshed object |
| post_update |
| This hook is run after the update() method has loaded and instantiated the object |
| pre_delete |
| This hook is run before the delete() has done anything |
| pre_delete_query |
| This hook is run after the delete() method has removed all relations from the object to be deleted |
| post_deleted |
| This hook is run after the delete() method has deleted the object |
u_print_r()
This is a version of print_r that accepts an ignore array: (Found on php.net)
/Customizable print_r variant.
Use only the $subject and $ignore parameters, the others are used internally
@param $subject The object/variable/array to be printed
* @param $ignore An array with the keys to ignore
* @param $depth Current depth (used in recursion)
* @param $refChain A chain of printed objects to avoid recursion
/
function u_print_r($subject, $ignore = array(), $depth = 1, $refChain = array())
{
if ($depth > 20) return;
if (is_object($subject)) {
foreach ($refChain as $refVal)
if ($refVal === $subject) {
echo "RECURSION*\n";
return;
}
array_push($refChain, $subject);
echo get_class($subject) . " Object ( \n";
$subject = (array) $subject;
foreach ($subject as $key => $val)
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth * 4) . '[';
if ($key{0} == "\0") {
$keyParts = explode("\0", $key);
echo $keyParts[2] . (($keyParts[1] == '') ? ':protected' : ':private');
} else
echo $key;
echo '] => ';
u_print_r($val, $ignore, $depth + 1, $refChain);
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
array_pop($refChain);
} elseif (is_array($subject)) {
echo "Array ( \n";
foreach ($subject as $key => $val)
if (is_array($ignore) && !in_array($key, $ignore, 1)) {
echo str_repeat(" ", $depth 4) . '[' . $key . '] => ';
u_print_r($val, $ignore, $depth + 1, $refChain);
}
echo str_repeat(" ", ($depth - 1) * 4) . ")\n";
} else
echo $subject . "\n";
}
The recommended ignore array is this:
array('instance','relations','relation_properties','data','mpttree','tree')
The mpttree and the tree are properties that the IgnitedRecord_tree behaviour uses
License
Copyright © 2008, Martin Wernstahl
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution. - The name of Martin Wernstahl may not be used to endorse or promote products
derived from this software without specific prior written permission.
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Martin Wernstahl BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Change Log
Version 0.1.1
Release Date: June 26, 2008
- Added the method uid() to IgnitedRecord_record
- Added yamlfactory()
- Added calls to DB_result::free_result() in all get methods, makes IgnitedRecord hog less memory and it becomes a bit faster
- Made the includes of the behaviour files relative to the ignitedrecord.php path
- Remade the factory() method, it now takes the tablename as the first parameter, and it is more effective, no more eval()
- get_modelname() now searches for models with tablename or singular of tablename both among the defined classes and in the CI object (propertyname = modelname)
- Tree behaviour:
- Added is_child_of() and is_descendant_of()
- Made the root cache per model instead of per object
- id column is now fetched from the IgnitedRecord object
- The behaviour now checks if MPTtree already is loaded before loading
- Fixed is_orphan()
- Fixed a typo in find_all_by(), forgot db and a 1 too much
Version 0.1.0
Release Date: May 30, 2008
- Limited support for multiple primary keys has been implemented.
- save() now returns true if the INSERT/UPDATE query succeeded.
- Added set_belongs_to(), set_has_many(), set_has_one() and set_habtm() (Has And Belongs To Many).
- factory() does not need the double underscores in the property names, double underscores are automatically added
- save() now only saves the record if it has been edited.
- Because of the new save(), a $force option has been added.
- The IgnitedRecordtree have got getdescendants().
- A custom loader has been implemented.
- Bugfixes:
- id column does not exist when creating a new record
- Misspellings and typos in the manual
Version 0.1.0 RC 4
Release Date: May 3, 2008
- Remade the structure for storing the relations, now supports multiple relations to the same table with the same type of relations (provided their relation names are different), check Establish Relationships
- Added error messages if a method was not found in the __call() methods
- Loading of relations logs a warning message if a relation between the tables does not exist
- Improved the strip_data() method a bit
- Added a custom MY_Loader.php
- The factory() method now prepends a double underscore on all propertynames in the second parameter
- Bugfixes:
- hooks() argument missing
- instance property not found
- relation_properties is not an array
Version 0.1.0 RC 3
Release Date: May 1, 2008
- Modified the hooks system, so references do work (if the recieving method takes the arguments by reference)
- Corrected the notice "Only variable references should be returned by reference"
- Made a check with references under PHP 4 (got db working, so now I can really test with PHP 4), so I believe they work as they should
Version 0.1.0 RC 2
Release Date: April 30, 2008
- Finally a name for this model, IgnitedRecord!
- The data is now sanitized before insert/update, it removes all properties that doesn't match the field names
- Added the get() method
- Added the factory() method, creates a new model instance from supplied settings
- Added the in_db() method (IgnitedRecord_record)
- Added Act_As, to enable easier customization of the IgnitedRecord class.
- Added a Child_class_helper array which contains all helper class names to be assigned to the child classes.
- Implemented a basic hook system.
- Added a lot of hooks into the main IgnitedRecord class.
- Added the ability to name relations, this enables the use of relations referring to self and has_many, belongs_to, has_one and has_and_belongs_to_many can relate to the same table without them overwriting eachother (useful for the Adjacency tree).
- Created a MPTtree behaviour, IgnitedRecordtree (requires MPTtree)
Version 0.1.0 RC 1
Release Date: April 5, 2008
- Initial Release