$model = new Users;
if (isset($_POST['Users'])) {
    $transaction=Yii::app()->db->beginTransaction();
    try {
        $model->attributes = $_POST['Users'];
        if ($model->save()) {
            $modelEmail = new Emails;
            $modelEmail->attributes = $_POST['Emails'];
            $modelEmail->iduser = $model->id;
            if ($modelEmail->save()) {
                $transaction->commit();
                $this->redirect(array('view', 'id' => $model->id));
            }
        }
        //something went wrong...
        $transaction->rollBack();
    }
    catch(Exception $e) { // an exception is raised if a query fails
        //something was really wrong - exception!
        $transaction->rollBack();
 
        //you should do sth with this exception (at least log it or show on page)
        Yii::log( 'Exception when saving data: ' . $e->getMessage(), CLogger::LEVEL_ERROR );
    }
}