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

[eluser]m4rw3r[/eluser]
Cascade on delete does not work with Belongs To relationships, because of the database layout.

It can be fixed, but delete() would be a bit messy if it is done.
So for now, it is only the "owning" part which can delete related records via cascades.

(but it would probably work with calling $record->related('name')->delete(); before you delete $record)

[eluser]m4rw3r[/eluser]
I have now converted most of the doc comments to PHPdoc, which probably make it easier to get an overview of the more intricate details of IgnitedRecord (but also IgnitedQuery).

I'm making the manual as a CI application, but I don't use db for it (maybe I will use it to allow comments in a php.net way).
The main reason behind making it a PHP app is that I don't want to rewrite the menu (or use JS) every time I make a new page / edits a title.
So I hope it won't be an annoyance to have to use a server to look at it (I'll see if I can easily make an offline version from the dynamic one).

[eluser]Muser[/eluser]
Hi,

Why behaviour is not being executed?


Model
Code:
class Vehicle extends IgnitedRecord {
    var $belongs_to = array('vehiclebrand','vehicletype');
    var $has_many = 'vehiclephotos';
    var $act_as = 'timestamped';
}

Controller

Code:
function add()
    {
        $this->output->enable_profiler = TRUE;

        $vehicle = $this->vehicle->new_record(
        array(
            'name' => 'Prius',
            'year' => '2005',
            'discataloged'  => FALSE,
            'vehicletype_id' => 1,
            'vehiclebrand_id' => 5
        )
        );

        print_r($vehicle);

        $vehicle->save();
    }

After printing the vehicle record with print_r() function, any timestamped hook are being attached to the record. It is like 'act_as' is not found.

[eluser]Muser[/eluser]
I've got these message in log:

ERROR - 2008-12-14 17:26:49 --> IgnitedRecord: Behaviour class IgnitedRecord_timestamped does not exists. Cannot load timestamped.

and I have application\libraries\ignitedrecord\behaviours\timestamped.php file

[eluser]m4rw3r[/eluser]
oops, I forgot to change the behaviour prefix for the timestamped behaviour when I changed it to IR_*.
It is now fixed.

[eluser]Muser[/eluser]
[quote author="Muser" date="1229293814"]I've got these message in log:

ERROR - 2008-12-14 17:26:49 --> IgnitedRecord: Behaviour class IgnitedRecord_timestamped does not exists. Cannot load timestamped.

and I have application\libraries\ignitedrecord\behaviours\timestamped.php file[/quote]

I'VE SOLVED IT.

IgnitedRecord is looking for a class name named 'IR_timestamped', and int timestamped.php behaviour file, the class is named 'IgnitedRecord_timestamped'. Changing the class name and contructor name from 'IgnitedRecord_timestamped' to 'IR_timestamped' now is working fine!

If you are using timestamped behaviour check if the class name is named 'IR_timestamped'

[eluser]Muser[/eluser]
[quote author="m4rw3r" date="1229294472"]oops, I forgot to change the behaviour prefix for the timestamped behaviour when I changed it to IR_*.
It is now fixed.[/quote]

Hey! Too much fast response!! I didn't saw it Wink

Thank you

[eluser]Muser[/eluser]
How can I get the id value (primary key value) inside a "save_pre_update" hook?

I only get a data array inside the hook callback, without the column id ...

[eluser]m4rw3r[/eluser]
Fixed.
The where array is now passed as the second parameter.

[eluser]Muser[/eluser]
Based on timestamped behaviour and Sluggable behaviour from Cakephp that I encountered on google, I've created a Sluggable behaviour for IgnitedRecord. This behaviour generates a slug value (search engine friendly url) from one or more labels given.

In this example:

Code:
class Vehicle extends IgnitedRecord {
    var $act_as = array('sluggable' => array('label' => array('name','year') ,'overwrite_on_update' => TRUE));
}

When vehicle is stored, a slug value is generated and saved in 'slug' column (by default, but the column name can be changed).
Code:
$this->load->orm('vehicle');
      $vehicle = $this->vehicle->new_record(
        array(
            'name' => 'Prius',
            'year' => '2005',
            'discataloged'  => FALSE
        )
        );
     $vehicle->save();

In the example, the slug generated is 'prius-2005'

For now, the labels are only fields from the table model (can not be columns from related tables for example). I don't know how to get it done this for now Sad



Grab the file from here:

http://code.google.com/p/muser/source/br...ggable.php

@m4rw3r: Thanks for the fix Wink




Theme © iAndrew 2016 - Forum software by © MyBB