Welcome Guest, Not a member yet? Register   Sign In
IgnitedRecord 1.0 pre-release

[eluser]the ronald[/eluser]
I think both suggestions would work good. Adding both would give the greatest amount of flexibility.

When setting the property in the model there could maybe be a method that could be called to escape the field if necessary.

class Foo extends IgnitedRecord{
    var $columns = array('date' => array('escape' => false),

Then in the controller say I was inserting a date but using php date functions..
$post = $this->post->new_record();
$post->escaped('date', date("Y-m-d"));

This would then give the ability to turn it off and on when needed.

I'm considering dropping support for CI's AR in IgnitedRecord.

Here is a list of reasons to why:

* IgnitedQuery is able to construct many queries at the same time
* IgnitedQuery has better performance
* IgnitedQuery has backwards compatibility (and it now supports the full feature set of CI's AR, I think)
* If IgnitedRecord only needs one base class it would be easier to mantain
* IgnitedQuery is capable of creating subqueries and nested wheres

I can only come up with two reasons to why not:

* CI's AR has been thoroughly tested
* CI's AR has more developers supporting the code

And now finally, here comes a question for you:

What do you think about dropping support for CI's AR?

Ok, here is an update:

I've decided to keep support for CI's AR in the next version (0.2.1) because I realized I had a few bugs to fix (all related to queries without caching + subqueries are fixed, so as long as you avoid caching with subqueries you should be safe).

The refactoring of the relation code has made me really happy: performance improvements, modularization, easier to maintain and easy to use in other parts of the code.

@All this babble about the DataMapper pattern:
When I started to develop IgnitedRecord I looked at the ActiveRecord implementation of Ruby, but I realized it wasn't flexible enough, so I put all database interaction methods in the model.
I didn't realize that I was following the DataMapper pattern, I didn't even know it existed until Micahel Wales posted a sneak peek of his DataMapper Smile

I just took what ideas I had and thought suitable and threw them into IgnitedRecord Tongue

Yeah m4rw3r, and I always thought patterns were the things dressmakers use. Who knew. :lol:

Keep up the good work man.

while MW's "sneak peek" of DataMapper creeps into official vaporware status, your very real contribution is changing the way people use CI -daily. thanks!

( insert smiley that means ::while recognizing MW's *chiefly* and valiant contributions to CI at the same time subtly pokes fun at him for pre-announcing a product by at least a month:: )

So I've got another problem.
$content = $this->input->post('content');
$name = $this->input->post('name');
$id = $this->input->post('id');// id = -1
$page = $this->page->find($id);// nothing found and return false
if ($page == FALSE){
   $page = $this->page->new_record();

$page->name = $name;
$page->content = $content;

After this MySQL drop error:
A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `name`, `content`) VALUES (, 'third', 'страница, созданная н�' at line 1

INSERT INTO `pages` (, `name`, `content`) VALUES (, 'third', 'страница, созданная не через БД')

Help me, what I'm doing wrong?

I've only seen this error in the SVN revisions of 0.2.1 and it has been corrected (or should be) in a later svn revision.

What svn revision are you using? Is it fixed in a later version?

Now it's worck, with last version from SVN.
Sorry for my panick.

Hi. I apologize in advance if this was already answered somewhere and I just couldn't find it.

I'm just starting out with CodeIgniter and want to implement something like the following

class FuRecord extends BarRecord {
var $_id;
var $_field1;

function getId() {return $this->_id;}

function getField1() { ... }
function setField1() { ... }

class BarRecord extends IgnitedRecord {
var $_id;
var $_field2;

function getId() {return $this->_id;}

function getField2() { ... }
function setField2() { ... }

These classes would correspond to the following database tables
Fu and Bar.

It seems from what I've read IgnitedRecord should allow me to set things up so that when I access the Fu record I will also read the corresponding Bar record. But I'm not sure how to connect (define them with the redefined relationships. or is there a better way that in my newness, I just haven't found.

Any help would be greatly appreciated.


The easiest thing to create custom record objects (That is what you want, right?) is to create a new class which extend the IR_record class:
class Foo_record extends IR_record{
    // a function that escapes the title (you can do whatever you like in the getters/setters you define
    function get_title(){
        return htmlentities($this->title);
Then in your model (The one extending IgnitedRecord), you define the child_class property as "Foo_record":
class Foo_model extends IgnitedRecord{
    var $child_class = 'Foo_record';
    // Then you can also create functions which help you to get things:
    function get_post(){
        $this->join_related('user', 'username');
        $post =& $this->get();
        $post->comments =& $post->related('comments')->order_by('posted')->get();
        return $post;

EDIT: I misunderstood your question (because the computer lags enormously, it's a wonder I can even write this).

No, IgnitedRecord cannot automatically, from inheritance, deduce what to fetch from where.
It assumes all data is coming from the table the model is mapped to.

So if you also want it to fetch data from the Bar table, you would probably use a Belongs To or Has One relationship between the records.
And then you would fetch the data from Fu with a JOIN with Bar:

Theme © iAndrew 2016 - Forum software by © MyBB