Accesso ad una basedati AS400 da PHP su Debian 11
Innanzi tutto occorre scaricare/avere i driver iAccess IBM, in questo caso su Linux il pacchetto ibm-iaccess-1.1.0.15-1.0.amd64.deb
Per interfacciarsi si passa attraverso una chiamata ODBC, quindi:
1 2 3 4 5 |
apt-get install unixodbc unixodbc-dev dpkg -i ibm-iaccess-1.1.0.15-1.0.amd64.deb apt-get install php-odbc odbcinst -i -d -f /opt/ibm/iaccess/unixodbcregistration nano /etc/odbc.ini |
Nel file di configurazione:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[MyDSN] Description = Company DB Driver = IBM i Access ODBC Driver System = myserver.mycompany.local UserID = username Password = password Naming = 0 DefaultLibraries = mylibrary Database = ConnectionType = 1 (0=read/write; 1=readonly) BlockFetch = 1 BlockSizeKB = 512 [MyDSN2] Description = Company DB2 Driver = IBM i Access ODBC Driver System = myserver2.mycompany.local UserID = username Password = password Naming = 0 DefaultLibraries = mylibrary Database = ConnectionType = 1 BlockFetch = 1 BlockSizeKB = 512 |
Esempio di accesso tramite PDO:
1 2 3 4 5 |
$pdo = new PDO("odbc:MyDSN"); $stmt = $pdo->query("SELECT * FROM mytable"); while ($row = $stmt->fetch()) { print_r($row); } |