0
$this->_connection = new PDO("odbc:Driver={SQL Server};Server=$serverName,1433; Database=".DB_NAME.";",DB_USER,DB_PASS);

This is my connection to database. I have installed php71-php-odbc.x86_64 0:7.1.9-1.el7.remi using the command yum --enablerepo=remi install php71-php-odbc it confirmed installation by

Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : php71-runtime-1.0-1.el7.remi.x86_64                                                                                                                  1/5
  Installing : php71-php-common-7.1.9-1.el7.remi.x86_64                                                                                                             2/5
  Installing : php71-php-json-7.1.9-1.el7.remi.x86_64                                                                                                               3/5
  Installing : php71-php-pdo-7.1.9-1.el7.remi.x86_64                                                                                                                4/5
  Installing : php71-php-odbc-7.1.9-1.el7.remi.x86_64                                                                                                               5/5
  Verifying  : php71-php-json-7.1.9-1.el7.remi.x86_64                                                                                                               1/5
  Verifying  : php71-php-odbc-7.1.9-1.el7.remi.x86_64                                                                                                               2/5
  Verifying  : php71-php-common-7.1.9-1.el7.remi.x86_64                                                                                                             3/5
  Verifying  : php71-php-pdo-7.1.9-1.el7.remi.x86_64                                                                                                                4/5
  Verifying  : php71-runtime-1.0-1.el7.remi.x86_64                                                                                                                  5/5

Installed:
  php71-php-odbc.x86_64 0:7.1.9-1.el7.remi

Dependency Installed:
  php71-php-common.x86_64 0:7.1.9-1.el7.remi  
  php71-php-json.x86_64 0:7.1.9-1.el7.remi  
  php71-php-pdo.x86_64 0:7.1.9-1.el7.remi  
  php71-runtime.x86_64 0:1.0-1.el7.remi

In the command line. The thing im confused is the output of print_r(PDO::getAvailableDrivers()); is

Array
(
    [0] => mysql
    [1] => sqlite
)

I am expecting that odbc will be added in the result. Also if i run php -m in the command there is no odbc in module list in command.

What is the correct way to install the driver need for the connection stated above.

Server runs centOS 7

Update

Installing odbc driver to get rid of error saying Caught exception: could not find driver

Manlapig
  • 33
  • 9

1 Answers1

0

1/ you have installed php71 which is a SCL (parallel installation), so ensure you use the right php command

# /opt/remi/php72/root/usr/bin/php -r 'print_r(PDO::getAvailableDrivers());'
Array
(
    [0] => dblib
    [1] => firebird
    [2] => mysql
    [3] => oci
    [4] => odbc
    [5] => pgsql
    [6] => sqlite
    [7] => sqlsrv
)

2/ Perhaps you need a single PHP version, check the wizard instructions

3/ More information red Microsoft SQL Server from PHP

Remi Collet
  • 6,198
  • 1
  • 20
  • 25
  • mate `/opt/remi/php72/root/usr/bin/php -r` after running it i get `bash: /opt/remi/php71/root/usr/bin/php: No such file or directory` does this mean something is wrong in my installation and that is the reason why i cant connect using `odbc`? – Manlapig Sep 22 '17 at 02:42
  • found your answer [here](https://stackoverflow.com/questions/37027457/php-with-mssql-not-installing-in-centos-7) i wanted to try it but i get error saying `Examining /var/tmp/yum-root-Om8xoE/epel-release-latest-7.noarch.rpm: epel-release-7-10.noarch /var/tmp/yum-root-Om8xoE/epel-release-latest-7.noarch.rpm: does not update installed package. Error: Nothing to do ` ***How to fix this?*** – Manlapig Sep 22 '17 at 03:16
  • Looks like you have install additional extensions as SCL (php71-php-*), when you need base package (php-*), see the Wizard: https://rpms.remirepo.net/wizard/ – Remi Collet Sep 22 '17 at 04:04