redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

using a controller



 
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum
View previous topic :: View next topic  
Author Message
plantino



Joined: 13 May 2006
Posts: 96
Hey.
If I'm inside a given controller and want to perform actions on another model than the one for that controller, how do I go about it?
Say I have a Foo model and a Bar model, and within my foos_controller.php I want to perform actions on my Bar model, how's the best way of going about it?
  Reply with quote


PaulKolin



Joined: 25 May 2006
Posts: 108
you can do $uses=array('Bar','Foo'); for loading 2 models
Var $uses
  Reply with quote
plantino



Joined: 13 May 2006
Posts: 96
Aha!
Cool, thanks
Hmm, I'm trying to do a find() with my model
But it's not *finding* anything
I'm doing $this->ModelName->find('"d = $id"); and it isn't returning anything
When I know for a fact that $id is a valid record in my model
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
D=$id ?
  Reply with quote
plantino



Joined: 13 May 2006
Posts: 96
Erm, id= even
$this->ModelName->find("id = $id");
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
Find(array('ModelName.id'=>$id))
Even better, $this->ModelName->id=$id; $data=$this->ModelName->read()
  Reply with quote
plantino



Joined: 13 May 2006
Posts: 96
That sounds simpler
If I want to modify that particular record, what's the synax?
Say I want to set Model.fieldname = value
After reading in $data, I could do $this->ModelName->save($data); right?
  Reply with quote
PaulKolin



Joined: 25 May 2006
Posts: 108
yep
  Reply with quote
plantino



Joined: 13 May 2006
Posts: 96
Thanks, I confirmed it Smile
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> PHP programming forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group