naveen kanni
naveen kanni

Reputation: 99

I am working on Windows server migration from 2008 R2 to 2019, getting oci_pconnect error when OCI module is present

I am facing a deadlock situation where when I run the extension_loaded(oci8) command through command prompt, it returns true but same the code returns false in a php function when loading the webpage.

I also checked php command to connect to Oracle DB and I was successful. But the same oci_pconnect throws a fatal error when called in a php function.

PHP version - 5.6.3 (x86), oracle instant client 12.1 (x86).

Configured FastCGI in IIS.

Below are the commands.

command:
php -r "echo (PHP_INT_SIZE == 4 ? '32 bit' : '64 bit').PHP_EOL;" && php -i | findstr Thread 

Output : 
32 bit | Thread safety => disabled.
command: 
php -r "echo extension_loaded('oci8') ? 'Yes' : 'No';"
Output : 
Yes
command: 
php -r "echo oci_pconnect('uname','pwd', 'oradb') ? 'Yes' : 'No';"
Output : 
Yes

When the same command (php -r "echo extension_loaded('oci8') ? 'Yes' : 'No';") is used in a php function it returns No and the php error log shows

Fatal error: Call to undefined function oci_connect()

Kindly let me know where I am wrong or if I need any additional set up.

Upvotes: 0

Views: 76

Answers (1)

hassan
hassan

Reputation: 8308

There are differences between running code with different SAPIs in PHP, when you are running your PHP under Web SAPI, under the hood, PHP uses different configurations for each SAPI. Enabling a PHP extension on a SAPI does not mean that it had been enabled on the other SAPI unless you have a built-in extension. For instance, if you built your PHP from source and included the oci8 extension within it, this meaning that the oci8 will be available through all different SAPI. On the other hand, if you are using oci8 as an extension, this means that you will need to enable / disable it for every different SAPI.

Basically PHP comes with a popular SAPIs like: apache2, cli, and fpm. if you want to use a specific extension on cli, you will need to explicitly enable it on cli, if you want to enable it on apache2 or fpm (for nginx), you will need to explicitly enable it for them too.

Upvotes: 0

Related Questions