I have a transaction where I am inserting a new record into TableB and depending if there is not the proper supporting record in TableA I will also be inserting into TableA and using that Primary Key as a Foreign key entry into TableB.

$transaction=$connection->beginTransaction();
try
{
$tableA->IsActive = 'Y';
$tableA->save();
$model->TableAId = $tableA->TableAId; //not sure what to put here for $tableA->TableAId
$model->save();
$transaction->commit();
}
In this situation can I use Yii::app()->db->getLastInsertId(); for $tableA->TableAId;
Obviously accuracy is highly important here so I need to guarantee that the proper records align between TableA and TableB
Basically, Your comment looks perfect. $model->TableAId = $tableA->TableAId; // This is perfect!!
But code not. Following should be your code.