当前位置:Gxlcms > 数据库问题 > yii链接postgresql

yii链接postgresql

时间:2021-07-01 10:21:17 帮助过:25人阅读

[ ‘class‘ => ‘yii\db\Connection‘, ‘dsn‘ => ‘pgsql:host=localhost;port=5432;dbname=exampledb‘, ‘username‘ => ‘dbuser‘, ‘password‘ => ‘abc123_‘, ‘charset‘ => ‘utf8‘, ];

  dbname是你的数据库名
  在controller中创建TestController.php文件, 创建访问Test测试

public function actionTest() {
    $test = Yii::$app->db->createCommand("UPDATE user_tbl SET name = ‘ttt‘ WHERE id =         9999991");
    return $test->execute();
}

  测试方法用来证明链接数据库正确, 其他修改数据库的操作自己研究
  cd 到你的项目目录, 运行php yii serve
  在浏览器访问方法: http://localhost:8080/controllers/test/test
  controllers是你的Controller所在目录,test问TestController.php, test是actionTest()方法

  

yii链接postgresql

标签:with   介绍   config   wget   数据库名   shell   测试   官网   post   

人气教程排行