Hi All,
I' ve got a problem with my self-join association. My model looks like
this:
<?php
class Project extends AppModel{
var $name = 'Project';
var $belongsTo = array(
'Assembly' => array(
'className' => 'Assembly',
'foreignKey' => 'assembly_id'
),
'Linker' => array(
'className' => 'Linker',
'foreignKey' => 'linker_id'
),
'Vector' => array(
'className' => 'Vector',
'foreignKey' => 'vector_id'
),
'User' => array(
'className' => 'User',
'foreignKey' => 'user_id'
)
);
var $hasMany = array(
'Child' => array(
'className' => 'Project',
'foreignKey' =>'parent_id'
)
);
var $hasOne = array(
'Precursor' => array(
'className' => 'Project',
'foreignKey' => false,
'conditions' => array('Project.parent_id' =>
'Precursor.id')
)
);
}
?>
The corresponding Controller-Part is following:
function view($id){
$project = $this->Project->read(null , $id);
$this->set('project', $project);
}
When I request the corresponding Array, i get this:
Array
(
[Project] => Array
(
[id] => 2
[parent_id] => 1
[name] => test_project_1
[created] => 2009-12-02 09:09:00
[trail_purpose] => testing
[description] => testing the self-join
[assembly_id] => 1
[user_id] => 18
[vector_id] => 1
[linker_id] => 1
)
[Assembly] => Array
(
[id] => 1
[name] => hg19
[genome] => human
[release_date] => 2009-02-01
[alternative_name] => GRCh37
)
[Linker] => Array
(
[id] => 1
[name] => test_linker
[sequence] => CCTAACTGCTGTGCCACT
[group_id] => 1
)
[Vector] => Array
(
[id] => 1
[name] => test_lenti
[type] => lenti
[lam_direction] => 5
[version] => 1
[sequence] => AAGGGTCTCGAGGATTCGAT
[ltr_id] => 3
[group_id] => 1
)
[User] => Array
(
[id] => 18
[first_name] => Tester
[last_name] => Testing
[login_name] => testUser
[password] => testing
[email] => [email protected]
[gender] => male
[degree] => none
[last_login] => 2009-12-02 07:57:07
[create_time] => 2009-12-02 07:57:07
[access_level] => read_only
[deleted] => 0
[group_id] => 1
)
[Precursor] => Array
(
[id] =>
[parent_id] =>
[name] =>
[created] =>
[trail_purpose] =>
[description] =>
[assembly_id] =>
[user_id] =>
[vector_id] =>
[linker_id] =>
)
[Child] => Array
(
)
)
You can see, that the self join relation could not be dissolved. So, I
could not display the name of the precursor as I want. Where is my
mistake.
Thank you in advance for your effort.
Thx, soleil83
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en