I just need someone to advise if on right track or not with my code.

In this case, when I create a record in one table, I need to create
three related records in another table.

I have used the $uses clause to set other models in use.

================ from users_controller =================
            function add()
            {
                if (!empty($this->data))
                {
                    if ($this->User->save($this->data))
                    {
                        $this->flash('User has been Created.','/users');


                        // Create 3 new entries in radcheck when creating new 
user.
                        // *******  look here ************
                        UsersController::createRadcheckEntries($this->data);
                    }
                }
            }

            // ****** LOOK here
            function createRadcheckEntries($data)
            {
                        pr($data);
                        $radcheckData =null;
                        $radcheckData['Radcheck']['UserName']= 
$data['User']['UserName'];
                        $radcheckData['Radcheck']['Attribute']= 'LM-Password';
                        $radcheckData['Radcheck']['op']='testop';
                        $radcheckData['Radcheck']['Value']='testdata';


                        $this->User->Radcheck->create();        // New record 
in model
                        $this->User->Radcheck->create();
                        $this->User->Radcheck->save($radcheckData);
            }
====================================

Question:
Does this look like the correct way to use cake?
There seems to be an lot of untyped array referencing. Can I make it
cleaner?

ALSO:
** Is it correct that the Model does not store data? I'm trying to get
my head around this. ie, do I have to create a data array and pass it,
just to do a save??
Is there no object oriented fields off the Model or am I just lost?

Thanks,

Pat.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to