You can't do that in *any* php class - you have to already have the class constructed before $this->name is set - so how would your class know how to set $this->name inside a property before instantiation? You *can* do this in the __construct( ... ) function.
On Sep 9, 10:28 am, lyba <[email protected]> wrote: > Any suggestions why it is not possible to join strings in a model > file: > > $foo = 'A'.'B'; > > this produces error: > Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION > in .\app\models\event.php on line 7 > > A real life scenario: > I have a model Event that has a self reference and is called under > different aliases (Event, PreviousEvent, NextEvent). > I need a virtual name for that model as an extract from the event > description > > this works: > public $virtualFields = array('name' => 'LEFT(description, 40)'); > but since model is called under different aliases in one request I get > warning: > Column 'description' in field list is ambiguous > > I thought this would work: > public $virtualFields = array('name' => 'LEFT('. $this->name .'.description, > 40)'); > > but then I discovered that joining strings in model does not work at > all. -- 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
