Tuesday, December 27, 2011

Re: Problem with relations

That sucks buddy, I got 99 problems but the b... oh, you mean, CakePHP/Database relations?

Never mind.

On Tue, Dec 27, 2011 at 4:13 PM, jmail <admin@jmail.pl> wrote:
Hi!

I've got question

how can I make HABTM relation?

I've got table shops with pk id column
I've got table couriers with pk id column
I've got table shops_couriers with pk id column and with shop_id and
courier_id columns

So I have provided into my Shop model

class Shop extends AppModel{
   public $hasMany = array('Offer');
   public $hasAndBelongsToMany = array(
       'Courier' =>
           array(
               'className' => 'Courier'
               ,'joinTable'              => 'shops_couriers'
               ,'foreignKey'             => 'shop_id'
               ,'associationForeignKey'  => 'courier_id'
           )
   );

   public $belongsTo = array('User');
}

and now when I try to go any fuction that using Shop model for example

public function index(){
       $this->set('shops', $this->Shop->find('all'));
       $this->layout = 'admlayout';
   }

I get error:

2011-12-27 22:08:25 Error: [MissingActionException] Action
XXXController::index() could not be found.
#0 XXX\lib\Cake\Routing\Dispatcher.php(104): Controller-
>invokeAction(Object(CakeRequest))
#1 XXX\lib\Cake\Routing\Dispatcher.php(86): Dispatcher-
>_invoke(Object(AdmshopsController), Object(CakeRequest),
Object(CakeResponse))
#2 XXX\app\webroot\index.php(96): Dispatcher-
>dispatch(Object(CakeRequest), Object(CakeResponse))
#3 {main}

Can someone help me?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


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

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
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

No comments: