Re: Working with INNER JOIN tables

2008-02-24 Thread gmail (codehooligans)

Taka,

I'm fairly new to Cake myself but can tell you that is you have your  
model setup correct to link the tables then this INSERT, UPDATE,  
DELETE will be taken care of (see further below). If you are running  
the INNER JOIN as some custom code in the controller then you are  
pretty much on your own. From what I know at the moment.

As an example of a setup model here is one I'm working with. This is a  
model for my Accounts table. There are two other tables in the system:  
Residence and User. The Residence table contains a field/column of  
'account_id'. This is the foreign key to the Account Table. The Users  
table contains a field/column of 'residence_id' This is the foreign  
key to the Residence table.

So to sort of draw things out we have the following 3-tier  
relationship between the Account, Residence and User table

Account - Residence (account_id) - User (residence_id).

What all this means and how things work is when I write code in the  
controller for say the View function I pass in an account_id. When the  
Account record is read in it automagically read in the referenced row  
from the Residence and the User tables as well. All 3 table sets are  
included at one. Nothing to worry about. Hope all this helps. And  
really I've only been working with Cake about a month. I'm sure one of  
the more experienced users on this list will comment I'm total F'in  
wrong.

Below is my actual model code. This was generated using the bake  
command. Note I had the MySQL tables already setup.


function view($id = null) {
if (!$id) {
$this-Session-setFlash('Invalid id for Account.');
$this-redirect('/accounts/index');
}
$this-set('account', $this-Account-read(null, $id));
}




?php
class Account extends AppModel {

var $name = 'Account';

//The Associations below have been created with all possible keys,  
those that are not needed can be removed
var $hasOne = array(
'Residence' =
array('className' = 'Residence',
'foreignKey' = 'account_id',
'conditions' = '',
'fields' = '',
'order' = '',
'dependent' = ''
),
'User' =
array('className' = 'User',
'foreignKey' = 'residence_id',
'conditions' = '',
'fields' = '',
'order' = '',
'dependent' = ''
),

);

}
?






On Feb 23, 2008, at 9:00 PM, takabanana wrote:


 Bueller?  :-)  Can anyone help, or point me in the right direction?
 Thanks!

 -taka

 On Feb 22, 1:06 am, takabanana [EMAIL PROTECTED] wrote:
 How does CakePHP handle (or With CakePHP, how do you do...) INSERT,
 UPDATE, and DELETE across multiple tables with an INNER JOIN query?

 sorry - still very very new to CakePHP.  Looking for books/tutorials
 in working with INNER JOIN table queries since my projects use  
 those a
 TON.

 Thanks for any help/pointers!

 -taka
 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Working with INNER JOIN tables

2008-02-23 Thread takabanana

Bueller?  :-)  Can anyone help, or point me in the right direction?
Thanks!

-taka

On Feb 22, 1:06 am, takabanana [EMAIL PROTECTED] wrote:
 How does CakePHP handle (or With CakePHP, how do you do...) INSERT,
 UPDATE, and DELETE across multiple tables with an INNER JOIN query?

 sorry - still very very new to CakePHP.  Looking for books/tutorials
 in working with INNER JOIN table queries since my projects use those a
 TON.

 Thanks for any help/pointers!

 -taka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Working with INNER JOIN tables

2008-02-23 Thread nate

See this thread:

http://groups.google.com/group/cake-php/browse_thread/thread/e9ca8f1e6fafb2af/f5233316033bc8b8

On Feb 23, 10:00 pm, takabanana [EMAIL PROTECTED] wrote:
 Bueller?  :-)  Can anyone help, or point me in the right direction?
 Thanks!

 -taka

 On Feb 22, 1:06 am, takabanana [EMAIL PROTECTED] wrote:

  How does CakePHP handle (or With CakePHP, how do you do...) INSERT,
  UPDATE, and DELETE across multiple tables with an INNER JOIN query?

  sorry - still very very new to CakePHP.  Looking for books/tutorials
  in working with INNER JOIN table queries since my projects use those a
  TON.

  Thanks for any help/pointers!

  -taka
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Working with INNER JOIN tables

2008-02-21 Thread takabanana

How does CakePHP handle (or With CakePHP, how do you do...) INSERT,
UPDATE, and DELETE across multiple tables with an INNER JOIN query?

sorry - still very very new to CakePHP.  Looking for books/tutorials
in working with INNER JOIN table queries since my projects use those a
TON.

Thanks for any help/pointers!

-taka

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Cake 
PHP group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---