-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pdo_oci in PHP 7 #10975
Comments
Have you tried PHP PDO drivers such as https://github.com/yajra/pdo-via-oci8 ? |
I'll try this: https://github.com/apaoww/yii2-oci8 ... Is it good? But anyway, I think this issue critical to the global adoption of yiiframework |
I have no idea if it's good. If it is, please confirm it here. We'll add it to offical guide. |
I tested both and had problems in CRUD and to connect to Oracle. Unfortunately, they are not fully ripe libraries. PHP 7 and YiiFramework without access to Oracle database via PDO layer :) |
@wwebdevelop you can compile the extension |
Hello df2, I tried to compile with PHP but gave error. |
@wwebdevelop if it matches your setup you can try this:
|
The OCI8 extension is installed. I can not is to install the pdo_oci |
Try this manual. I did not test it on PHP7, but maybe it will work |
No success :( |
These aren't PDO. |
That's right, Samdark. There's been a misunderstanding. You see, there is nothing wrong with the OCI8 extension. It continues to be maintained and actively increased by Oracle. Now you see the problem involving Yii. Access to databases of Yii2 was entirely Constructed under the PDO layer. Only now, with version 7 of PHP, there is no active and valid extension pdo_oci. I spoke via Facebook with Wez Furlong, founder of pdo_oci extension - it does not work more with it. See: https://pecl.php.net/package/PDO_OCI Thus, Yii does not work with Oracle databases when running in an environment with PHP 7. In my humble opinion, Yii should use from the beginning OCI8 and OCI11 extension since they were created by Oracle are actively maintained and have numerous features and optimizations that pdo_oci not have. Yii in their next releases must implement a solution to work around this limitation, under penalty of having their impaired worldwide adoption. The Lavarel, for example, is supported via OCI8. For me this is extremely worrying regarding the adoption of the framework for enterprise applications involving Oracle databases. |
The link I've posted above (https://github.com/yajra/pdo-via-oci8) is PDO based on oci8 from the same guy who maintains unofficial Laravel driver. There are more: |
If you read carefully the article posted by SilverFire
In fact if you download php7 sources you find it, and looking at code comments you can easily verify that is for php7 At first you need to install oracle client and sdk, use the full version of the oracle client. The instruction to compile pdo_oci are for debian/ubuntu system, but is easy to adapt for other systems. Php7 source download Compiling Installing enable the new php module restart php fpm or apache if you installed php as apache mod service php7.0-fpm restart Works done! Hope it helps others. Maybe some note can be inserted in the manual so the people know that pdo_oci has been revamped by Oracle and yii2 is fully working with php7. |
Getting The problem is charset in connection string Any ideas? |
Are you sure you are using Basic oracle client ? |
Yes, of course. I am using Basic client and I've got this file. |
Does it connect by using plain connection? (by removing charset=UTF8 so if use default charset) |
Yes, it connects without charset, but we are getting incorrect data. |
I'm looking pdo_oci code. In oci_drive.c there is the part that initialize the connection. /* allocate an environment */
#if HAVE_OCIENVNLSCREATE
if (vars[0] . optval) {
H->charset = OCINlsCharSetNameToId(pdo_oci_Env, (const oratext *)vars[0] . optval);
if (!H->charset) {
oci_init_error("OCINlsCharSetNameToId: unknown character set name");
goto cleanup;
} else {
if (OCIEnvNlsCreate(&H->env, PDO_OCI_INIT_MODE, 0, null, null, null, 0, null, H->charset, H->charset) != OCI_SUCCESS) {
oci_init_error("OCIEnvNlsCreate: Check the character set is valid and that PHP has access to Oracle libraries and NLS data");
goto cleanup;
}
}
}
#endif It seem that is not a problem with an unknown charset but more that the driver is unable to locate the instantclient (gogoled around about OCIEnvNlsCreate) |
Yes, I've tried to set ORACLE_HOME and LD_LIBRARY_PATH in php-fpm config and in php-fpm init.d script. Nothing changed for me. |
Side note: sqlplus works fine with my ORACLE_HOME |
Saw you answer after posting . 'db' => [
'class' => 'yii\db\Connection',
'dsn' => 'oci:dbname=//localhost:1521/XE',
'username' => 'MYDB',
'password' => 'password',
'on afterOpen' => function($event) {
//$event->sender refers to the DB connection
$event->sender->createCommand("ALTER SESSION SET NLS_TERRITORY = 'ITALY'")->execute(); Change according you country. The above set various things charset, numeric separator, date format ordering and so on. $event->sender->createCommand("ALTER SESSION SET NLS_LANG = 'ITALIAN_ITALY.UTF8'")->execute(); |
in yii/db/Connection.php
Nothing changed. |
Hummm using
Are you running your sqlplus with the same user of your php/webser? |
Yes. 😞 |
in phpinfo()
|
@bobonov Thank you for replies. |
I had difficult too using the charset via dsn, but in my case no error but oracle was ignoring it. |
Hello, @bobonov ps. We try it in OpenServer+php7 and it work fine when you adding charset to dsn |
I can solve the problem :) |
Solved this problem today. In my case the problem was only in 1 environment variable: ORACLE_HOME. So my solution was add this: |
Did anyone face PHP Startup: Unable to load dynamic library '/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20151012/pdo_oci.so' i got that file but cant load. know why? |
How did you got the file? Did you compile it? On the target machine did you install the oracle client? |
hi bobonov, I managed to compile and get the pdo_oci.so. But when I load and print phpinfo. The php error log shows this. I get from Php source I successfully compile with oracle client. but fail to load. u guys can load? |
Which server (ubuntu, centos...) are you running and which version? if you do at command line: |
i m using mac. for local use. not server |
version PHP 7.0.13 |
Yes bro. The file is there. |
I am PHP 7.1.30 with apache2.4.34 on Debian. I faced the same error. I installed three packages using dpkg.
Post installation, We need to remove the libphp.so file from apache modules to get it replaced when we recompile and install php. When recompiling use these options, I'm using oci in 2019 it still works I think its not true that it php 7+ version won't support Oracle with pdo-oci. |
Thanks @samdark your suggestions were too useful for me |
I was two days trying to install the extension pdo_oci in PHP7 on a CentOS 7, however when running the command "pecl install pdo_oci" returns me a message saying that the extension is deprecated for version 7 of PHP.
When trying to compile PHP extension as the PHP manual also generates errors.
The concern is, how Yii works with PDO believe that there is no support today for Oracle database. In fact PHP 7 does not support the Oracle database via pdo_oci
I spoke via chat with Wez Furlong, creator of pdo_oci, and he said he no longer works on it for years.
Accessing the page PECL, there is a warning that pdo_oci is no longer maintained: https://pecl.php.net/package/PDO_OCI
Only with the OCI8 extension could not connect to the oracle. Is there any way to do it?
I think that would be the time Yii incorporate into your core something that circumvents this issue. Or in the case of Oracle, using the OCI8 - that developed and actively maintained by Oracle.
The text was updated successfully, but these errors were encountered: