Just noticed Yii::app()->db->getLastInsertId() works only after an insert or update transaction and also if you have the primary key auto incremented, in that case $model->id is also available which is the id of the last inserted item.
If you just want to find out the last inserted id (not after an insert or update) you might try something like this (AGAIN, PK SHOULD BE AUTOINCREMENTED)
$lastId = Yii::app()->db->createCommand('SELECT id FROM yourTable ORDER BY id DESC LIMIT 1')->queryScalar();
this will pull out the maximum value off the yourTable.