Not able to connect mssql server - "driver not found error"

I am using Ubuntu 16.04

php version : php 7.2

When tried to connect MySQL server with the yii2 application I got an error ,below pasted

Database Exception – yii\db\Exception
could not find driver

Caused by: PDOException
could not find the driver
in /home/loremine/websites/rentandservices.local/vendor/yiisoft/yii2/db/Connection.php at line 719

Here I wish to connect both MySQL and SQL servers at the same time for the same application

For a set of functions,I need to connect SQL server.More specifically for two functions.Except that the entire website will connect to the MySQL database. Mysql works perfectly,but mssql server returns error
Connection string pasted here.Here I used a remote connection .Also tried with local DB.Returns the same error
‘db’ => [
‘class’ => ‘yii\db\Connection’,
‘dsn’ => ‘mysql:host=localhost;dbname=rns_staging_6’,
‘username’ => ‘root’,
‘password’ => ‘quickstart’,
‘charset’ => ‘utf8’,
‘queryCacheDuration’=>1

    ],
'db1' => [
  'class' => 'yii\db\Connection',
  'driverName' => 'sqlsrv',
  'dsn' => 'sqlsrv:Server=50.201.227.146;Database=Y21',
  'username' => 'lm21user',
  'password' => 'Y2!ldn21amz1',

 'charset' => 'utf8',
 'queryCacheDuration'=>1

],

Please help

here the sample of db config

<?php

return [

    'class' => 'yii\db\Connection',

    'dsn' => 'mysql:host=localhost;dbname=your_db',

    'username' => 'root',

    'password' => 'your_password',

    'charset' => 'utf8',

];

Thank you for the reply.

Actually, I want to connect with the mssql server and not with MySQL.MySQL config works perfectly. but MSSQL server is not able to connect. That is my problem. I am using PHP 7.2 with the latest version of the MSSQL server. Kindly check and update me.The error pasted here

maybe you can read this

Hi,
Thank you for the reply.let me check and update
Thanks & Regards
Maya A

Hi,
Sorry for the late reply.I was busy with another task.

Thank you for your support. Issue Fixed.

And I need one more help please
I am using two DB connections at the same time. Please see the configuration below.

‘db’ => [
‘class’ => ‘yii\db\Connection’,
‘dsn’ => ‘mysql:host=192.168.1.3;dbname=rns_staging_6’,
//‘dsn’ => ‘mysql:host=localhost;dbname=rns_staging_6’,
‘username’ => ‘rns’,
‘password’ => ‘quickstart’,
‘charset’ => ‘utf8’,
‘queryCacheDuration’=>1

],

‘db1’ => [
‘class’ => ‘yii\db\Connection’,
‘driverName’ => ‘sqlsrv’,
‘dsn’ => ‘sqlsrv:Server=50.201.227.146;Database=Y21’,
‘username’ => ‘lm21user’,
‘password’ => ‘Y2!ldn21amz1’,
‘charset’ => ‘utf8’
],

And my timezon settings is here.
private function configGlobalEventSubscriptions(){
\yii\base\Event::on( \yii\db\Connection::className()
, \yii\db\Connection::EVENT_AFTER_OPEN
, function ($event) {
echo ‘

’; \yii\helpers\VarDumper::dump($event->sender); die();
$event->sender->createCommand(“SET time_zone = ‘+00:00’;”)->execute();
});

}

This line returns an error on connecting MSSQL(db1 connection) . How can I solve this problem?

The error is shown on the MSSQL server connection

‘SQLSTATE[42000]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Incorrect syntax near ‘=’.’

in /app/web/vendor/yiisoft/yii2/db/Command.php:1302

Kindly check and update