First, this is a thesaurus dictionary script.
There is a `thesauruses` database. Two models have access to it:
Thesaurus (by convention) and Synonym (public $useTable =
'thesauruses';).
Then I use HABTM relation ship to get all synonyms related to a words,
that is: thesauruses -> synonyms_thesauruses -> thesauruses.
So I come to this:
$this->Thesaurus->bindModel(array(
'hasAndBelongsToMany' =>
array(
'Synonym' => array(
'joinTable' => 'synonyms_thesauruses',
'className' => 'Synonym',
'foreignKey' => 'thesaurus_id',
'associationForeignKey' => 'synonym_id'
),
)
));
Output:
app\controllers\thesauruses_controller.php (line 96)
Array
(
[Thesaurus] => Array
(
[id] => 12055
[word] => nosis
)
[Synonym] => Array
(
[0] => Array
(
[id] => 12056
[word] => snapas
[SynonymsThesaurus] => Array
(
[id] => 12473
[thesaurus_id] => 12055
[synonym_id] => 12056
)
)
[1] => Array
(
[id] => 12057
[word] => knabÄ—
[SynonymsThesaurus] => Array
(
[id] => 12474
[thesaurus_id] => 12055
[synonym_id] => 12057
)
)
...
And here is where I am stuck.
Now I need every Synonym to be related with a Property (in database
that would look like [SynonymsThesaurus][thesaurus_id] ->
properties_thesauruses -> property). That would be OK if I had only
one property, though, I don't.
So I need final output to be something similar to:
Array
(
[Thesaurus] => Array
(
[id] => 12055
[word] => nosis
)
[Synonym] => Array
(
[0] => Array
(
[id] => 12056
[word] => snapas
[SynonymsThesaurus] => Array
(
[id] => 12473
[thesaurus_id] => 12055
[synonym_id] => 12056
)
[property] => Array
(
[0] => Array
(
[id] => 12
[property] => 'low'
)
[1] => Array
(
[id] => 16
[property] => 'high'
)
)
)
...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment