Yii2框架连接华为云dws配置
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Yii2框架连接华为云dws配置相关的知识,希望对你有一定的参考价值。
1、在Yii2框架 /common/db.php
$dev = [
‘class‘ => ‘yiidbConnection‘,
‘dsn‘ => ‘pgsql:host=127.0.0.1;port=8000;dbname=info‘,
‘username‘ => ‘admin‘,
‘password‘ => ‘admin‘,
‘charset‘ => ‘utf8‘,
‘emulatePrepare‘ => true,
‘schemaMap‘ => [
‘pgsql‘=> [
‘class‘=>‘yiidbpgsqlSchema‘,
‘defaultSchema‘ => ‘portal‘ //默认视图
]
],
‘on afterOpen‘ => function($event) {
// $event->sender refers to the DB connection
$event->sender->createCommand("SET CURRENT_SCHEMA = ‘public‘")->execute();//执行sql语句设置视图
}
];
2、在models类
public static function queryEndToEndAudioRecv($params)
{
$start = microtime(true);
$find = static::find();
$find->andWhere(‘log_time>=‘ . $params[‘startTime‘]);
$find->andWhere(‘log_time<=‘ . $params[‘endTime‘]);
$list= $find->select(‘user_id,recvbr,lost_rate,rcarton,recvuid,log_time‘)
->orderBy(‘log_time asc‘);
->asArray()
->all();
$sql = $find->createCommand()->getRawSql();//生成查询语句
$end = microtime(true);
ll(‘耗时(秒):‘ . ($end - $start) . ‘sql:‘ . $sql, ‘dwsSql.log‘);
return $list;
}
以上是关于Yii2框架连接华为云dws配置的主要内容,如果未能解决你的问题,请参考以下文章