Gettting the install directory

I want to create a link in an email to be sent, so I need an absolute URL.  What is the best way to go about this and how can Yii tell me the base URL of the application?

For instance I want to generate the link: <a href="http://localhost/yiiTest/etc">test</a>

and it should automatically change when I move the application / upload to production server

It should take the url routes into account also.

Although it seems simple I can not find where to get this information

thanks

Yii::app()->request->hostInfo . Yii::app()->request->baseUrl

Works great, but maybe this should be made easier?  Maybe add an argument to CHtml::link or something if it should be absolute?  I believe CakePHP adopts this.  Or at least put it all in one variable.

Also, how can I retrieve the ID of the last inserted row?  It looks like Yii is supposed to automatically update the primarykey after an insert but it does not seem to be working.

I am simply calling $user->id in a view after an insert

Thanks,

Jonah

I added a parameter to getBaseUrl. Now you can use Yii::app()->getBaseUrl(true) to get an absolute URL.

Yes, the ID should be automatically populated if it is auto-incremental. Which database are you using? Are you sure the PK column is auto-incremental?

Thanks, the update seems to be working.

As for the id, that was my bad.  I was trying to find it in the beforeSave() method. silly me.  It actually works great.