Thanks axel for your answer.
Result is :
Array
(
[0] => Array
(
[Item] => Array
(
[name] => Beruang Kuning
[item_id] => 3
)
[Vendor] => Array
(
[name] => Malang Boneka
[vendor_id] => 5
)
[Tag] => Array
(
[0] => Array
(
[name] => Toy
)
)
)
Same with my first :
$joinRecords=$this->Item->find('all',array('fields' =>
array('Item.name'),'contain' => array('Tag.name','Vendor.name')));
debug($joinRecords);
maybe i still use bind and unbind behavior :D
Thanks
On 8/18/08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> $joinRecords=$this->Item->find('all',array('contain' =>
>
> array('Tag.name','Vendor.name'),
> 'fields'=>array('name')));
>
>
> Yodi Aditya wrote:
> > Hello,
> > I have some problem with containable Behavior. I have 3 model Item,
> > Tag and Vendor.
> > This is the models :
> >
> > class Item extends AppModel {
> > var $name = 'item';
> > var $belongsTo = array('Vendor' =>array(
> > 'className' => 'Vendor'));
> > var $hasAndBelongsToMany = array('Tag' => array(
> > 'className' => 'Tag',
> > 'joinTable' => 'items_tags',
> > 'associationForeignKey' => 'tag_id'));
> > }
> >
> > class Tag extends AppModel {
> > var $name = 'Tag';
> > var $hasAndBelongsToMany = array(
> > 'Item' => array(
> > 'className' => 'Item',
> > 'joinTable' => 'items_tags',
> > 'associationForeignKey' => 'item_id',
> > ),
> > );
> > }
> >
> > class Vendor extends AppModel {
> > var $name = 'Vendor';
> > var $hasMany = 'Item';
> > }
> >
> > Tags_controller and Vendor_controller using scaffolding. I set
> > Item_controller like this :
> >
> > class ItemsController extends AppController {
> > var $name = 'Items';
> >
> > function index() {
> > $this->Item->field('name');
> > $this->Item->Behaviors->attach('Containable');
> > $joinRecords=$this->Item->find('all',array('fields' =>
> > array('Item.name'),'contain' => array('Tag.name','Vendor.name')));
> > debug($joinRecords);
> > }
> > }
> >
> > In my Firefox, the result is :
> > Array
> > (
> > [0] => Array
> > (
> > [Item] => Array
> > (
> > [name] => Beruang
> > [id] => 3
> >
> > )
> >
> > [Vendor] => Array
> > (
> > [name] => GooMan
> > [id] => 1
> > )
> >
> > [Tag] => Array
> > (
> >
> > [0] => Array
> > (
> > [name] => toy
> > )
> >
> > )
> >
> > )
> >
> > Then i change
> > $joinRecords=$this->Item->find('all',array('fields' =>
> > array('Item.name'),'contain' => array('Tag.name','Vendor.name')));
> > with
> > $joinRecords=$this->Item->find('all',array('contain' =>
> > array('Tag.name','Vendor.name')));
> >
> > Result is :
> > Array
> > (
> > [0] => Array
> > (
> > [Item] => Array
> > (
> > [id] => 3
> > [name] => Beruang
> >
> > [width] => 40
> > [height] => 30
> > [created] => 2008-06-07 21:28:12
> > [modified] => 2008-08-04 14:55:08
> > [status] => 1
> >
> > [slug] => beruang
> > [vendor_id] => 1
> > )
> >
> > [Vendor] => Array
> > (
> > [name] => GooMan
> > )
> >
> >
> > [Tag] => Array
> > (
> > [0] => Array
> > (
> > [name] => boneka
> > )
> >
> > )
> >
> >
> > )
> >
> > I want result is just name like this :
> > Array
> > (
> > [0] => Array
> > (
> > [Item] => Array
> > (
> > [name] => Beruang
> >
> > )
> >
> > [Vendor] => Array
> > (
> > [name] => GooMan
> > )
> >
> > [Tag] => Array
> > (
> > [0] => Array
> >
> > (
> > [name] => boneka
> > )
> >
> > )
> >
> > )
> >
> > Can anybody help me, what should i do?
> >
> > >
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---