Hi,

I have a model called "Setup" and another called "SetupSession" and I
was trying to return a new instance of "Setup" from a method on
SetupSession however I can't seem to get it to work.

My function looks something like this:

// in setup_session.php

    function getNextLapSetup($userId, $raceId) {
        $count = $this->find('count', array(
                    'conditions' => array('SetupSession.user_id' =>
$userId, 'SetupSession.race_id' => $raceId)));

        if ($count > 0) {
        $count = $this->find('first', array(
                    'conditions' => array('SetupSession.user_id' =>
$userId, 'SetupSession.race_id' => $raceId)));
               // create a new Setup and populate it based on data
retrieved above

              // What needs to go here??

        } else {
            // return an empty Setup
        }
    }

In the bit where it says "// What needs to go here??" I've tried a few
things like:

$temp = new Setup();
$temp->data['Setup']['user_id'] = $userId;
// etc
return $temp

But it seems the "data" array (or map, not sure what it's called??) is
undefined.

I also tried the above with $temp->create() after the first line as
well, but am facing the same issue.

Essentially I want to call this function from the controller.  It will
return a new "Setup" model prepopulated with "suggested data", but I
do not require it to be saved to the db until the user reviews it and
re-submits.

I'm primarily a  ColdFusion programmer and new to CakePHP and my PHP
skills are pretty basic so it's entirely possible I'm completely on
the wrong track here.  Is anyone able to advise me what I need to
change to get this working please?

Many thanks,
Andrew.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to