personnal class

Hi

I need to create a class under the model folder in order to respect the MVC structure and benefits from the autoloading features. The class beeing created aims to deal with data files, so this class is neither a form nor an active record.

I’ve tried the following code from a freshly Yii installation just to see if all is ok

the class "MessageBuilder" is saved into a file named MessageBuilder.php under the model folder.

class MessageBuilder

{

private $_message='';


	


public function getMessage()


{


	return $this->_message;


}





public static setMessage($text)


{


	$this->_message=$text;


}

}

then from a controller named message I try to invoque theses functions

class MessageController extends Controller

{

public $message='';





public function actionSend()


{


	$newMessage = new MessageBuilder


	$newMessage->setMessage('this is a message');


	$message=$newMessage->getMessage();


	$this->render('send');


}

finaly the wiew render the var $message

But the only thing I gett is a blank screen without any error messages to help me.

If I comment out the following lines

            $newMessage = new MessageBuilder


	$newMessage->setMessage('this is a message');


	$message=$newMessage->getMessage();

the view is working as normaly.

someone can help me ?

You need to change third line in your MessageController’s actionSend() function:

to


	$this->message=$newMessage->getMessage();



thanks a lot it’s now working