Ok, so what happens if you aren't taking in data from a form?

For instance, in my example, I'm trying to loop through data from a
flat table, format it into an array, and call saveAll() on it to build
relational data.

A rough idea of what I'm trying to do:

+++++++++++++++++++++++++++++++++++++++++++++++++
foreach($raw_data as $data) {
 $formatted_data_array = array (
                    'Business' =>  array ('name' => $data['raw_data']
['name']),
                    'BusinessPhone' => array (
                        'phone_number' => $data['raw_data']['phone'],
                        'reg_business_id' => 1
                    ));

  $this->Business->create();
  $this->BusinessPhone->create();
  if(!$this->Business->saveAll($formatted_data_array))
      //output error
}
+++++++++++++++++++++++++++++++++++++++++++++++++

In the above extremely rough code, the business data will save but the
phone data never gets saved.  Inside the Business model, there's a
hasOne relationship to BusinessPhone (using a foreign key in the
business_phones table called business_id).

As you can see, the inserted foreign key in the BusinessPhone model
will never be valid (right now it's always 1) even if the saveAll
worked properly, because I have no way to know what it is when I build
the array being sent to saveAll().

Any ideas?

- Cake Fan

On Jan 4, 2:47 pm, rtconner <[EMAIL PROTECTED]> wrote:
> http://groups.google.com/group/cake-php/browse_thread/thread/d097212f...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to