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

[eluser]helmutbjorg[/eluser]
One thing I love about IgnitedRecord is the naming conventions. You have made a very, VERY simple code system.

$object = $this->model->new_record();
$object->property = 'nice';
$object->save();

$objects = $this->model->join_related('thing')->find_all();
$things = $object->related('things')->get();

It just flows so well and it is quite clear that you have worked hard and used common sense and simplistic conventions. Unlike some other ORMs that look like a bag of shit. Can I request that you keep this up the top of your list for your next project.

As recent example just taking a look at the CIExtended orm code makes me want to throw up compared to the ignitedrecord code.

[eluser]m4rw3r[/eluser]
IgnitedRecord is not a dead project, but it is on a hiatus for now. I don't know when I will continue on it (although I don't see myself doing major work on it, more like I will fix minor things).

I started to rewrite my new ORM from scratch yesterday, primarily because the code builder I made for it did not really work in a manner which was flexible enough. The major reason for that is the way the configuration objects were structured.

The new configuration is handled by objects which the user have a direct influence over, the descriptors.
A descriptor describes a class and also provides the occasional code piece for the code builder, which makes for an easy and powerful way of extending the code.

And yes, I'm trying to keep the same sane defaults I made for IgnitedRecord in my new ORM. The flow is quite similar and the loading of related records must be explicitly called, just as in IgnitedRecord.

Example:
Code:
class User
{
    public $id;
    public $name;
    public $posts = array();
}
class UserDescriptor extends Db_Descriptor
{
    function __construct()
    {
        $this->add($this->newPrimaryKey('id'));
        $this->add($this->newColumn('name'));
        
        // Automatically figures that it is a has many relationship:
        $this->add($this->newRelation('posts'));
    }
}

class Post
{
    public $id;
    public $user_id;
    public $title;
}
class PostDescriptor extends Db_Descriptor
{
    function __construct()
    {
        $this->add($this->newPrimaryKey('id'));
        $this->add($this->newColumn('user_id'));
        $this->add($this->newColumn('title'));
    }
}

$u = Db::find('user')
    ->where('user.id', 2)
    ->related('posts')
    ->like('user-posts.title', 'foobar')
    ->getOne();

echo $u->name;

foreach($u->posts as $p)
{
    echo $p->title;
}

If you want to have a look at the code, look here: http://github.com/m4rw3r/RapidDataMapper/tree/master

If you'd like to have a special feature, just send me a message (or add a ticket).
I have a lot of features I've made in the earlier version, before the rewrite, which means that those will be quite quick to implement.

[eluser]Christian Haller[/eluser]
Hi,
I have a related_by problem.

Here is my example:
Every Posts is written by an user.

So, the
Code:
$post->user_id
is pointing to
Code:
$user->id
.

I want to fetch all posts and echo the $post->title and the $user->name (or is it $post->user->name?)

I need an example for my models (user and post) and the controller.

How can I fetch all posts and the user names?

It should be like this

Code:
foreach($posts as post){
  echo $post->title.'-----'.$post->user->name;
}
Every help is welcome!
Thank you very much.

Christian

[eluser]Christian Haller[/eluser]
ok, my problem is solved.
I LOVE THIS LIB!

[eluser]helmutbjorg[/eluser]
Hello Martin (and whoever else reads this),

A situation has come up where i need to modify a table and add a column just before an update on an ignitedrecord model. All good however just as I had suspected when the model is first loaded, ignitedrecord must inspect the database and identify the columns in the table. The problem is that if I modify the columns on the fly then when I add data to the new column, ignitedrecord ignores it because it doesn't know about the column.

Eg..
Code:
// Get field name based on posted name
$field = strtolower(url_title($this->input->post('name')));
// Make a field matching the name for this table
if(!$this->db->field_exists($field, 'people')) {
    $this->load->dbforge();
    $this->dbforge->add_column('people', array($field=>array('type'=>'VARCHAR','constraint'=>'250')));
}                
// All good, save to the database
$data['person']->name = $this->input->post('name');
$data['person']->$field = 'Yes this field works';
$data['person']->save();
This is just example code to test my proof of concept.

Is there some way to tell ignitedrecord to reload the model? Or is there some way we can unload the model and then reload it? Or is there some other way I can let ignitedrecord know about the new column name for that model?

Thanks for your help... Sorry it is a bit of a crap question.

[eluser]helmutbjorg[/eluser]
I may have solved it with the following code. Note the two extra lines adding the table columns to the model object.

Code:
// Get field name based on posted name
$field = strtolower(url_title($this->input->post('name')));
// Make a field matching the name for this table
if(!$this->db->field_exists($field, 'people')) {
    $this->load->dbforge();
    $this->dbforge->add_column('people', array($field=>array('type'=>'VARCHAR','constraint'=>'250')));
    // Manually add the table columns so ignitedrecord saves em
    $this->person->columns = $this->db->list_fields('people');
    $this->person->columns[] = $field;
}                
// All good, save to the database
$data['person']->name = $this->input->post('name');
$data['person']->$field = 'Yes this field works';
$data['person']->save();

If you can see a better way please let me know. Thanks!

[eluser]Kaosland[/eluser]
Hello,

I have a litte problem.
the function delete() don't work.

[eluser]Kaosland[/eluser]
Hello

I want to pick up an bug.

when i want this

table 1 anime
Table join
table image

$image=$this->anime->related(R_IMAGES_ANIMES)->where('image_id', $id)->get();

if i do $image->name, error call no objet.

but when i do a var_dump$image) i

public '__data' => array 'id' => string '72' (length=2) 'name' => string 'ce25e09cd1f725ad71c8b509390a9519.png' (length=36) 'height' => string '180' (length=3) 'width' => string '545' (length=3) 'type' => string 'anime' (length=5) 'theme_id' => null 'created_at' => string '2010-10-31 17:06:49' (length=19) 'created_by' => string '0' (length=1) 'updated_at' => string '2010-10-31 17:06:49' (length=19) 'updated_by' => string '0' (length=1)

SO IR find bit i can't use!!

If somebody can help me.




Theme © iAndrew 2016 - Forum software by © MyBB