if(!isset($this->ModelName){
$this->ModelName->loadModel();
}
This only works in the controller, but it should get you what you want if I
understood the question correctly.
Sincerely,
Michael Stelly
mobile: +1.918.978.2000
skype: mjstelly
LinkedIn <http://www.linkedin.com/in/mstelly>
On Sat, May 5, 2012 at 8:34 PM, CakeNino <[email protected]> wrote:
> I am new to CakePHP and am building an application to help learn the
> framework. I am having a problem trying to instiate one model from
> another model. Here is the basic premise...
>
> Assume a simple application - I have Feeds (as in RSS Feeds) and
> Content. I want to create a page that grabs an RSS feed, loops
> through each of the items, and saves each item in separately in the
> Content table. Here is what I would LIKE to do - but have problems.
> My problems may be both conceptual and/or syntax related.
>
>
>
> In the FEED model, I created a function called processFeedContent.
> Here is how I would like it to work (written in psuedo-code):
>
>
>
> public function processFeedContent($feedUrl = null) {
>
> $xml = Xml::build($feedUrl);
> $x_array = Xml::toArray($xml);
> $contents = $x_array['rss']['channel']['item'];
>
> for each($contents as $content) {
> $title = $content['title'];
> $link = $content['link'];
>
>
> //THIS IS THE PART I NEED HELP WITH.
> //THE CODE BELOW IS WHAT I WOULD LIKE TO DO IN
> PSUEDO CODE
>
> //STEP 1 - Instantiate an empty Content
> Object
> $myContent = $this->Create('Content');
>
> //STEP 2 - Set appropriate values in the newly
> created object
> $myContent->set('title', $title);
> $myContent->set('link', $link);
>
>
> //STEP3 - Save the New Object
> $myContent->save();
> }
> }
>
>
>
> ANy help or guidance will be greatly apprecaited
>
> --
> 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
> [email protected] 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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php