I am trying to get my head wrapped around using components. I've got a table of rectangles. A typical record would be an id, width, and height: id : 2x4 b: 1.5 h: 3.5
I've got the typical setup: M: Rectangle C: RectanglesController V: index, add, edit, view I would like to calculate other properties of a rectange like perimeter, area, moment of inertia, etc. I do not need to store these in the database, since they are derived from b & h. For my view.thtml view I'd like to see something like: id : 2x4 b: 1.5 in h: 3.5 in A: 5.25 in^2 Sx: 3.063 in^3 etc. I'd like to create a Rectangle class/object to encapsulate these properties. Is a Component the best place to do this? Can I put it in / components/rectangle.php and call it: class Rectangle extends Object ...? Or will there be a name confict since the Model is also called Rectangle? For the sake of eliminating confusion I'm calling the component Foo. Here's what I've got which doesn't work: In the controller: var $components = array('Foo'); function index() { $recordset = $this->Rectangle->findAll(null, null, 'id ASC'); // Calculate additional rectangle properties and add them to the recordset foreach ($recordset as $record => $values) { $rect = $this->Foo($values['b'], $values['h']); $values['A'] = $rect->A; } $this->set('rectangles', $recordset); } I'd like to instantiate the Foo object like $rect = new Foo($width, $height) but I don't know how to do this in the controller. Any light that could be shed on this would be appreciated. Thanks, Brian --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---