PHP MySQL Yii-无法读取数据库

我的本​​地灯泡堆上有一个正在工作的Yii应用程序.现在,当我将应用程序放置在灯泡服务器上时,该应用程序将读取数据库并运行,但是该应用程序未成功写入数据库.我没有错误日志.有什么想法吗?

I have a working Yii app on my local lamp stack. Now when I put the app on a lamp server the app reads the db and runs, but the app isn't successfully writing to the db. I'm getting no errors logs. Any thoughts?

这是我更新数据库的方式:

Here's how I'm updating the db:

public function actionIndex()
{
    if ($_GET["yep"] == "") {
      pd_error("You are not logged in!");
    }
    list($uid, $domain) = preg_split("/@/",$_GET["yep"],2);
    $model=$this->loadModel($uid);
    $this->redirect($model->URL."?".$model->Unique_ID);     
}

public function loadModel($uid)
{
    $model=People::model()->findByPk($uid);
    $model->Login_Count++;
    $model->Last_Logged=date('Y-m-d H:i:s');
    if ($model->validate()) {
         $model->save();
    } else { 
        $this->render('notice');
    }
    return $model;
}

奇怪的是,即使数据库没有更新Login_Count和Last_Logged,用户仍然会重定向到其url,因此sql必须有效,因为通知页面永远不会加载.有什么想法吗?

The weird thing is, even when the db doesn't update the Login_Count and Last_Logged the user still gets redirected to their url, so the sql must be valid because the notice page never loads. Any thoughts?

问题最终是由于mysql服务器将autocommit设置为false.要在应用程序级别覆盖此设置,请在config/main.php db数组中添加以下行:

The problem ended up being that the mysql server had autocommit set to false. To override this at the app level add the following line to the config/main.php db array:

'db'=>array(
    ...
    'initSQLs'=>array('SET AUTOCOMMIT=1',),
    ...
);

Yii:在关闭自动提交的情况下使用活动记录mysql服务器



 1 条回答