If you already got the parent_id filled out, just use the recover 
functionality of the behavior
Either from console (CLI) via shell or from your controller action call 
$this->Model->recover()
This should fix your lft/rght fields based on your parent_id


Am Mittwoch, 7. August 2013 19:03:52 UTC+2 schrieb Mohammad Naghavi:
>
> I had this model for a long time and my table and model already has 
> parent_id and existing data inside the table has relations. The new fields 
> added are lft and rght which has for now only NULL values inside. I want to 
> fill these in a way that the tree behavior can be used with this existing 
> data and relation.
>
> Regards,
> Mohammad
> On Aug 7, 2013 6:18 PM, "euromark" <[email protected] <javascript:>> 
> wrote:
>
>> Do not forget the parent_id
>>
>> Also, what do you mean with existing data?
>> By default it would all be just a flat list (none of them would have a 
>> parent).
>> This is also a valid tree
>>
>> How would you be able to tell which is the parent of which?
>> If it can be automated, there is an easy way to do that with Cake.
>> But first, you need to find out how it can be automated. Otherwise you 
>> need to manually
>> edit each record.
>>
>>
>> Am Mittwoch, 7. August 2013 17:03:25 UTC+2 schrieb Mohammad Naghavi:
>>>
>>> Hi all,
>>> this is straight forward, I have a bid table, which used parent_id to 
>>> make a threaded hierarchy. now after a time that the application is used, 
>>> I'm facing problems that can be done perfectly using tree behavior. I have 
>>> added the lft and rght columns but can find an easy way to convert existing 
>>> data into a tree behavior compatible form. 
>>>
>>> the last way is to make a temporary table, read from current and write 
>>> into new, and later swap old with new and remove the old, but I have too 
>>> much data in the table that it may not be possible at least at once.
>>>
>>> do you have any idea how to do it easier? It can be done also directly 
>>> in DB (mysql).
>>>
>>> Thanks in advance for any suggestion.
>>> Mohammad
>>>  
>>  -- 
>> Like Us on FaceBook https://www.facebook.com/CakePHP
>> Find us on Twitter http://twitter.com/CakePHP
>>  
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> Visit this group at http://groups.google.com/group/cake-php.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to