Php Yii:是否在静态页面中更新(Model';s)表列?

Php Yii:是否在静态页面中更新(Model';s)表列?,php,yii,Php,Yii,我正在使用一个静态页面来执行一些操作,我想知道如何从模型中更新某些数据。 对于这个例子,我想处理一个虚拟支付。登录用户有一定数量的信用(“yii用户扩展的tbl_配置文件中的信用”列),代码检查产品价格并从用户信用中减去: $productid = $_GET['product']; $user = Yii::app()->getModule('user')->user()->profile; $userid = Yii::app()->user->id; $cre

我正在使用一个静态页面来执行一些操作,我想知道如何从模型中更新某些数据。 对于这个例子,我想处理一个虚拟支付。登录用户有一定数量的信用(“yii用户扩展的tbl_配置文件中的信用”列),代码检查产品价格并从用户信用中减去:

$productid = $_GET['product'];
$user = Yii::app()->getModule('user')->user()->profile;
$userid = Yii::app()->user->id;
$credits = Yii::app()->getModule('user')->user()->profile->credits;
$product = Product::model()->findByPk($productid);
$price = Product::model()->findByPk($productid)->price_total;

if($credits >= $product){
$newcredits = ($credits - $price);
//Update 'credits' for logged in user
}else{
//Payment Failed
echo "Not enough credits";
}

在本例中,如何更新登录用户的积分?

我不知道yii用户扩展名,但似乎

Yii::app()->getModule('user')->user()->profile;
返回概要文件模型,该模型可能是活动记录

以下代码可能会更改信用

Yii::app()->getModule('user')->user()->profile->credits = $newcredits;
Yii::app()->getModule('user')->user()->profile->save();

我不知道yii用户扩展,但看起来

Yii::app()->getModule('user')->user()->profile;
返回概要文件模型,该模型可能是活动记录

以下代码可能会更改信用

Yii::app()->getModule('user')->user()->profile->credits = $newcredits;
Yii::app()->getModule('user')->user()->profile->save();