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

What you can do is to use the dbobj2orm() method of IR_base (which means that all models extending IgnitedRecord has it) to convert an object of db_result into IR_records (or whatever class is specified).

To easily make a query to the database, create an instance of IgnitedQuery, it is IR's replacement of ActiveRecord and is made as a stand alone lib too (I've just made IR_base extend IgnitedQuery to get the SQL building methods).

Example usage:
// in the model:
function &foo;()
    // This is also the usage if you want to use it as a stand alone lib, which works perfectly fine:
    $query = new IgnitedQuery();
    $query->select('foo, bar'); // Just treat it as if you use CI's $this->db
                                // (but there are differences, at least with 1.7 of CI)
    $query->from($this->table); // We make it dynamic, so we can reuse the code
    $result = $query->get();    // Just as a normal CI query

    return $this->dbobj2ORM($result); // now we let dbobj2ORM do its magic :)
    // (pass true as the second parameter if you only want a single IR_record returned,
    // otherwise the records are encapsulated in an array)
I do hope the sum functions work as they should, I've primarily tested all where and like statements.

$this->select(array('ThicknessNameOut', 'WidthNameOut', 'LengthNameIn'));
$this->where('BoardFeetIn > ', 1);
return $this->find_all();

This worked in 0.2.0 but fails, as you described, in 1.0 because there is a
that was added to the running of the find_all. It is useful to have that select all in there but it would be nice to be able to go around it.

The reason I have this code:
Is because I don't want to have the JOINs messing with the most important part of the query, the "main" object(s) to fetch (if a join is specified, IR won't have any selectors for the "main" table).

Actually, if you want to call the IgnitedQuery::get() from the IgnitedRecord class, you should be able to call it as a static method:
function foo()

    $q =& IgnitedQuery::get($this->table);

    return $this->dbobj2ORM($q);

Excellent, thank you very much!

Hi. find_by_sql and find_all_by_sql doesnt work.

Message: Undefined property: User::$db

Filename: ignitedrecord/ignitedrecord.php

Line Number: 869

I think $this->db - doesnt exists).


Corrected it (the db property isn't needed, but I overlooked those methods when I removed $this->db).

I am trying to use CI Template Parser library(only accepts arrays) and IgnitedRecord library to pass the data using for example; But I need for this to work I would need to be able get the result from IgnitedRecord as an array and not an object, I am unable to figure out a good way to do this can any one help me out.

class Contents extends IgnitedRecord{


class Content extends Controller{

function Content()

   $this->load->orm('Content', 'content_mod');


function index()
   $data['content'] = $this->content_mod->find_all(); // This will return an Object Array and not Array
   $this->parser->parse('content_page', $data);




Is there a way i can go around this, if there is can you help me out with an example I will really appreciate it.

This is the error I get

A PHP Error was encountered

Severity: 4096

Message: Object of class Content could not be converted to string

Filename: libraries/Parser.php

Line Number: 104

Thank you!!

quick, but not tested...

does this help?
$data['content'] = (array)$this->content_mod->find_all();

Thanks sophistry but I got the same error!!!

The problem there is that the type-casting isn't recursive, and you'll end up with an array of objects (which it already was).
You need to make it recursive (and also to ignore properties like __instance).

I'm currently at school, so I'll post something when I get home.

Theme © iAndrew 2016 - Forum software by © MyBB