-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
I have Laravel 8 project with (PHP version 7.4). I have also setup database credentials in database.php file. When i tried to fetch record from database in controller, then this error came.
ErrorException Undefined index: database
extension installed on server
Here is db credentials are like this
'db2' => [
'driver' => 'db2_ibmi_ibm',
'driverName' => '{IBM i Access ODBC Driver}',
'host' => '172.23.10.1',
'username' => 'PB_WEB_FL',
'password' => 'edT323_74T',
'database' => 'BRAX',
'prefix' => '',
'schema' => 'default schema',
'port' => 80000,
'date_format' => 'Y-m-d H:i:s',
// or 'Y-m-d H:i:s.u' / 'Y-m-d-H.i.s.u'...
'odbc_keywords' => [
'SIGNON' => 3,
'SSL' => 0,
'CommitMode' => 2,
'ConnectionType' => 0,
'DefaultLibraries' => '',
'Naming' => 0,
'UNICODESQL' => 0,
'DateFormat' => 5,
'DateSeperator' => 0,
'Decimal' => 0,
'TimeFormat' => 0,
'TimeSeparator' => 0,
'TimestampFormat' => 0,
'ConvertDateTimeToChar' => 0,
'BLOCKFETCH' => 1,
'BlockSizeKB' => 32,
'AllowDataCompression' => 1,
'CONCURRENCY' => 0,
'LAZYCLOSE' => 0,
'MaxFieldLength' => 15360,
'PREFETCH' => 0,
'QUERYTIMEOUT' => 1,
'DefaultPkgLibrary' => 'QGPL',
'DefaultPackage' => 'A /DEFAULT(IBM),2,0,1,0',
'ExtendedDynamic' => 0,
'QAQQINILibrary' => '',
'SQDIAGCODE' => '',
'LANGUAGEID' => 'ENU',
'SORTTABLE' => '',
'SortSequence' => 0,
'SORTWEIGHT' => 0,
'AllowUnsupportedChar' => 0,
'CCSID' => 819,
'GRAPHIC' => 0,
'ForceTranslation' => 0,
'ALLOWPROCCALLS' => 0,
'DB2SQLSTATES' => 0,
'DEBUG' => 0,
'TRUEAUTOCOMMIT' => 0,
'CATALOGOPTIONS' => 3,
'LibraryView' => 0,
'ODBCRemarks' => 0,
'SEARCHPATTERN' => 1,
'TranslationDLL' => '',
'TranslationOption' => 0,
'MAXTRACESIZE' => 0,
'MultipleTraceFiles' => 1,
'TRACE' => 0,
'TRACEFILENAME' => '',
'ExtendedColInfo' => 0,
],
'options' => [
PDO::ATTR_CASE => PDO::CASE_LOWER,
PDO::ATTR_PERSISTENT => false
]
// + (defined('PDO::I5_ATTR_DBC_SYS_NAMING') ? [PDO::I5_ATTI5_ATTR_DBC_SYS_NAMINGR_COMMIT => false] : [])
// + (defined('PDO::I5_ATTR_COMMIT') ? [PDO::I5_ATTR_COMMIT => PDO::I5_TXN_NO_COMMIT] : [])
// + (defined('PDO::I5_ATTR_JOB_SORT') ? [PDO::I5_ATTR_JOB_SORT => false] : [])
// + (defined('PDO::I5_ATTR_DBC_LIBL') ? [PDO::I5_ATTR_DBC_LIBL => ''] : [])
// + (defined('PDO::I5_ATTR_DBC_CURLIB') ? [PDO::I5_ATTR_DBC_CURLIB => ''] : [])
],
In controller, I have done like this
$products = LeiobjProduktP::limit(1)->get(); return response()->json(['products' => $products]);
On hosting server, Db2 can not access using odbc driver.
I have done simple PHP script to make connection with db. it worked successfully. Here is script
$host = 'dummy'; // The IP address or hostname of your IBM i server
$database = 'dummy'; // The name of your database on the IBM i system
$username = 'test'; // Your database username
$password = 'test'; // Your database password // Construct the ODBC connection string
$port = 80000;
$dsn = "DRIVER={IBM i Access ODBC Driver};DATABASE=$database;SYSTEM=$host;Port=$port;PROTOCOL=TCPIP";
$connection = db2_connect($dsn, $username, $password); // Check if the connection was successful
if ($connection) {
echo "Connected to the IBM i database."; // Perform database operations here
db2_close($connection); // Close the database connection when done
} else {
echo "Failed to connect to the IBM i database.";
}

Please guide regarding this.
Jozaru27
Metadata
Metadata
Assignees
Labels
No labels
