apioo / fusio

Open source API management platform
https://www.fusio-project.org
Apache License 2.0
1.85k stars 221 forks source link

Fusio connection to MS SQL server #171

Open jan-sp opened 6 years ago

jan-sp commented 6 years ago

Hello,

I have installed Fusio on a Ubuntu 16.04. works as expected mostly, however I want to use it to connect to an MS SQL server, and there I have an issue....

When setting up a connection to the MS SQL server, I get an error Call to undefined function Doctrine\DBAL\Driver\SQLSrv\sqlsrv_configure() in /var/www/fusio/vendor/fusio/impl/src/Service/Connection.php on line 219

I've implemented the MS Drivers and can connect whitout problem to our MS SQL server with sqlcmd. ` sqlcmd -S 10.xxx.xxx.xxx -U SomeUser -P VeryC0p!exP@ssw0rd -Q "SELECT @@VERSION"


Microsoft SQL Server 2014 (SP2-GDR) (KB4057120) - 12.0.5214.6 (X64) Jan 9 2018 15:03:12 Copyright (c) Microsoft Corporation Enterprise Evaluation Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor) `

A second issue (and I'm convinced both are related) is that I can't update the installation via composer. I Get this message: composer update fusio/impl PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/sqlsrv.so' - /usr/lib/php/20151012/sqlsrv.so: cannot open shared object file: No such file or directory in Unknown on line 0 Composer could not find a composer.json file in /root To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section

Any suggestions on this issue(s)?

I would realy get this working, because Fusio is a great project!

Kind regards, Jan

chriskapp commented 6 years ago

Hi, first thanks the great response. From the error message I would guess that the PHP sqlsrv extension is not installed and therefor the sqlsrv_* functions are not available. It looks like the PHP extension /usr/lib/php/20151012/sqlsrv.so file is missing. So iam not sure how you have install the extension but you might want to take alook directly at the repo https://github.com/Microsoft/msphpsql how to properly install the extension. It looks like they have a great getting started guide: https://www.microsoft.com/en-us/sql-server/developer-get-started/php/ubuntu/

jan-sp commented 6 years ago

Hi,

Indeed, the file(s) mentioned in your reply were missing....

Found this post on https://github.com/Microsoft/msphpsql/issues/736

Hi @niheno

For security reasons, since the latest version we have changed to immediate binding, thus affecting how our drivers are loaded. Please remove the lines concerning pdo_sqlsrv.so in your php.ini files and follow the instructions here .

Hope this helps.

I followed the instructions:

And bingo! Fusio made a successful connections to MS SQL

Concerning the second part of my initial post, there's still an issue with updating the installation composer update fusio/impl PHP Warning: Module 'sqlsrv' already loaded in Unknown on line 0 Composer could not find a composer.json file in /root To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section although its an other message than before

Kind regards Jan

chriskapp commented 6 years ago

Sounds great. Regarding your last warning, I think the extension is probably referenced in the php.ini twice so PHP tries to load the extension despite it is already loaded.

gil0109 commented 4 years ago

I had the same issue and finally install it thanks the comments above. Now I get the following error: SQLSTATE [IM004, 0]: [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed in /var/www/html/fusio/vendor/fusio/impl/src/Service/Connection.php on line 228

I am running in Openshift and I am wondering if it is because of a write issue with ODBC?

UPDATE: FIXED -- The following helped if anyone else has this issue: https://stackoverflow.com/questions/55474713/drivers-sqlallochandle-on-sql-handle-henv-failed-0-sqldriverconnect-when-co

I checked and the sqlsrv module is installed:

php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
igbinary
intl
json
libxml
mbstring
memcached
mongodb
msgpack
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pgsql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
sodium
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache
php -i |grep pdo
/etc/php/7.2/cli/conf.d/10-pdo.ini,
/etc/php/7.2/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.2/cli/conf.d/20-pdo_pgsql.ini,
/etc/php/7.2/cli/conf.d/20-pdo_sqlite.ini,
API Extensions => mysqli,pdo_mysql
pdo_mysql
pdo_mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
pdo_pgsql
pdo_sqlite
pdo_sqlsrv
pdo_sqlsrv support => enabled
pdo_sqlsrv.client_buffer_max_kb_size => 10240 => 10240
pdo_sqlsrv.log_severity => 0 => 0
FUSIO_DB_TYPE => pdo_pgsql
$_SERVER['FUSIO_DB_TYPE'] => pdo_pgsql