cooperl22 / laravel-db2

laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.
Other
59 stars 65 forks source link

Problem (and solution) on IBMI with driver db2_ibmi_ibm #59

Open AlexandreBeauduin opened 4 years ago

AlexandreBeauduin commented 4 years ago

Hi,

I just installed Laravel 6.12.0 and Cooperl/laravel-ibmi on Zendserver 2019.0.3 on IBMI (PHP version 7.2.24). I copied the config from this github page and replaced database, username, password, ... to my needs. driver => db2_ibmi_ibm

When I make a query (through Model or DB facade, I get:

PDOException {#256 ▼

message: b"SQLSTATE=42705, SQLConnect: -950 DRIVER={IBM i Acce absente du répertoire des bases de données relationnelles."

code: 0

file: "/www/zendphp7/htdocs/twins_api_l6/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php"

line: 70

+errorInfo: null trace: {▶} }

To fix this, I had to go Cooperl\Database\DB2\Connectors\IBMConnector and replace this line :

$dsn = "ibm:DRIVER={$config['driverName']};DATABASE={$config['database']};HOSTNAME={$config['host']};PORT={$config['port']};PROTOCOL=TCPIP;";

with this one: $dsn = "ibm:{$config['database']}";

Then it works.

After doing this, I can even comment out the host, driverName and port from config/database.php, it still works.

I tried to find more info on the DSN and how to "write" it but did not find any clues on how to specify the host, port, etc...

Is it normal ? What did I miss ?

Sorry for my bad English :)

CedricGnn commented 2 years ago

Hi,

Is there any news about this issue ?

Can we implement something like $config['dsn'] to replace the whole getDsn() method ? Like if there's a dsn configuration then we don't have to get it from getDsn(), preventing the issue and keeping the feature usable ?

Thanks a lot.