php - Yii-User 模块中的配置文件字段修改

标签 php yii yii-extensions

我已经安装了 yii-user 并且想要使用配置文件字段。我通常检索我需要的字段,如下所示:

Yii::app()->getModule('user')->user()->profile->firstname

但问题是如何从另一个 Controller 更改配置文件表字段,例如名字、姓氏等?

Yii-user模块本身已经创建了profiles表。

最佳答案

经过很多麻烦和深入研究代码,我终于成功了。
我实际需要的是使用 Yii::app()->getModule('user')->user()->profile 加载配置文件模型,然后使用 setAttributes 设置配置文件字段值。最后但并非最不重要的一点是使用 save() 来保存我的更改。

            $profileModel = Yii::app()->getModule('user')->user()->profile;
            $profileModel->setAttributes(array('balance'=>1200));
            $profileModel->save();   

这可能对其他人有帮助。 ;-)
干杯!

关于php - Yii-User 模块中的配置文件字段修改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24614414/

相关文章:

yii - 如何将下载的扩展添加到 yii 1.11?

php - mysql选择具有最高最大值的行

具有 HTML 格式的 PHP 变量

php - PHP返回mp3文件

javascript - Yii- 客户端验证不适用于 CActiveForm

php - 单击时 %40 变为 %2540

php - 如何使用 codeigniter 按类别显示产品

javascript - 无法包含 JavaScript

module - Yii中Modules和extension的区别

php - Yii2:使用Kartik Depdrop小部件?