PHP.mk документација

Oracle PDO драјвер

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

ref.pdo-oci.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека ref.pdo-oci.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
Oracle PDO драјвер

Референца за `ref.pdo-oci.php` со подобрена типографија и навигација.

ref.pdo-oci.php

Oracle PDO драјвер (PDO_OCI)

Инсталација

Ако Oracle базата на податоци е на истата машина како PHP, софтверот за базата на податоци веќе ги содржи потребните библиотеки. Кога PHP е на различна машина, користете го бесплатниот » Oracle Instant Client библиотеки. За детали погледнете ги OCI8 Барања section.

PHP 8.4

Овој екстензија е преместен во (достапно од PHP 7.2.0) PHP 8.4

repository and is no longer bundled with PHP as of PHP 8.4.0 Инсталација на PECL екстензииInformation for installing this PECL extension may be found in the manual chapter titled » https://pecl.php.net/package/PDO_OCI.

. Additional information such as new releases, downloads, source files, maintainer information, and a CHANGELOG, can be located here:

од PHP 8.0.0. Силно се обесхрабрува потпирањето на оваа функција. --with-pdo-oci[=DIR] за инсталирање на PDO Oracle OCI екстензијата, каде што опционалното [=DIR] е директориумот Oracle Home. [=DIR] по основно е $ORACLE_HOME променливата на околината.

од PHP 8.0.0. Силно се обесхрабрува потпирањето на оваа функција. --with-pdo-oci=instantclient,prefix,version за Oracle Instant Client SDK, каде што се конфигурирани префикс и верзија.

// Using $ORACLE_HOME
$ ./configure --with-pdo-oci

// Using OIC for Linux with 10.2.0.3 RPMs with a /usr prefix
$ ./configure --with-pdo-oci=instantclient,/usr,10.2.0.3

Претходно дефинирани константи

Константите подолу се дефинирани од овој драјвер и ќе бидат достапни само кога екстензијата е компајлирана во PHP или динамички вчитана при извршување. Дополнително, овие константи специфични за драјверот треба да се користат само ако го користите овој драјвер. Користењето атрибути специфични за драјверот со друг драјвер може да резултира со неочекувано однесување. Добиј информации за MySQL хост Константите подолу се дефинирани од овој драјвер и ќе бидат достапни само кога екстензијата е или компајлирана во PHP или динамички вчитана во време на извршување. Покрај тоа, овие константи специфични за драјверот треба да се користат само ако го користите овој драјвер. Користењето атрибути специфични за драјверот со друг драјвер може да резултира со неочекувано однесување. PDO::ATTR_DRIVER_NAME може да се користи за добивање на

PDO::OCI_ATTR_ACTION (int)

Обезбедува начин за специфицирање на акцијата на сесијата на базата на податоци.

Ова постои од PHP 7.2.16 и 7.3.3

PDO::OCI_ATTR_CLIENT_INFO (int)

Обезбедува начин за специфицирање на информациите за клиентот на сесијата на базата на податоци.

Ова постои од PHP 7.2.16 и 7.3.3

PDO::OCI_ATTR_CLIENT_IDENTIFIER (int)

Обезбедува начин за специфицирање на идентификаторот на клиентот на сесијата на базата на податоци.

Ова постои од PHP 7.2.16 и 7.3.3

PDO::OCI_ATTR_MODULE (int)

Обезбедува начин за специфицирање на модулот на сесијата на базата на податоци.

Ова постои од PHP 7.2.16 и 7.3.3

Содржина

  • PDO_INFORMIX DSN — Поврзување со Oracle бази на податоци

Белешки од корисници 8 белешки

Волфганг Ридман
пред 2 години
An important hint: if you are using prebuilt PHP packages where PDO_OCI is not compiled in, you should download the original PHP sources for the PHP version your server is using.
These sources contain the PDO_OCI source in the ext/pdo_oci directory.
Change to that directory, build the module using 
phpize
./configure
make
and then install the newly build module to your PHP extension directory and add it to your configuration.
For me this has worked on a Debian server with the sury.org modules (PHP 8.2).
cursade на hotmail точка com
19 години пред
if oracle and oracle instant client has been installed,
without db in the same host

For UNIX/LINUX,set $LD_LIBRARY_PATH
appent your instant client path  and  client/lib path to it,

For windows set PATH like this

After set the path ,set TNS_ADMIN everioment ,point to 
where  tnsnames.ora located.

Then,you can use service name to connect to your Database

Test coding

<?php
$param = $_POST;
$db_username = "youusername";
$db_password = "yourpassword";
$db = "oci:dbname=yoursid";
$conn = new PDO($db,$db_username,$db_password);
$name = $param['module'];
$file = $param['file'];
$stmt = $conn->exec("INSERT INTO AL_MODULE (AL_MODULENAME, AL_MODULEFILE) VALUES ('$name', '$file')");

?>
php на ideacode точка com
пред 14 години
If you're getting the "I'm too dumb to find oci.h" error, try creating a variety of paths.  One variety uses just the major and minor of your OIC version (eg, 11.2 for 11.2.0.2) and another variety uses client64 as well as client.

Something like this (for 11.2.0.2):
ln -s /usr/include/oracle/11.2.0.2/ /usr/include/oracle/11.2
ln -s /usr/include/oracle/11.2/client /usr/include/oracle/11.2/client64
ln -s /usr/lib/oracle/11.2.0.2/ /usr/lib/oracle/11.2
ln -s /usr/lib/oracle/11.2/client /usr/lib/oracle/11.2/client64

This should cover your bases for 64-bit systems, as well as PHP patched to use the major.minor version number only.  See also PHP bug #44989.
fernando точка wendt на gmail точка com
пред 17 години
To enable PDO support on PHP for Oracle Instant Client 11.1.x, you should follow the syntax above in the compile command, just as pointed by Andrew http://bugs.php.net/bug.php?id=39312, taking by default you have installed the OIC at /usr/lib/oracle (instant client and sdk at subfolder):

./configure --with-oci8=shared,instantclient,/usr/lib/oracle
--with-pdo-oci=instantclient,/usr/lib/oracle,11.1

Just saying your release version from the Oracle OIC.

It compiles fine then.

Best regards.
wriedmann на gmail точка com
Nimja
As addition to what I wrote 2 years ago:
if you are installing on Debian with a Debian provided package, install the source with 
apt source php8.2
Then you have to set ORACLE_HOME like that:
ORACLE_HOME=/usr/lib/oracle/19.6
export ORACLE_HOME
before running ./configure.
After that, I had to add the include directory 
-I/usr/include/oracle/19.6/client64/
into the Makefile to successfully build the module.
redlorry919 на gmail точка com
пред 14 години
Take note of the note at the top, this really is an experimental extension. I had a problem trying to read data from Oracle which resulted in some strange behaviour in PHP. i.e. foreach loops not ending, with no error messages. I also managed to get the data from Oracle into an array in PHP, but then couldn't return the array from a function.

After pulling my hair out for a day, it turned out to be a CLOB column in Oracle that caused the strange behaviour in PHP. I assume this extension doesn't fully support them.

Instead I've typecast it within the SQL to a VARCHAR2 which seems to resolve it:

SELECT CAST(columnx AS VARCHAR2(4000)) AS columnx ...

It might help someone else having similar issues.
[email protected]
19 години пред
A Statement of Warning:

PDO::oci does not support REF CURSORS.

This is mentioned nowhere (until now!) on this page. 

And now you know!

If you want ref cursors avoid PDO for now. 

My Reference for this claim:
http://www.oracle.com/technology/pub/articles/
php_experts/otn_pdo_oracle5.html

GREAT article, excellent piece, really. It's not clear to me 
how old this document is, but it must have some dust on it, 
given it's references to "PHP5.1 ...' which is a little way off yet' "
... as of 2006-06-01, PHP5.1 has been with us for quite some time.
mta59066 на gmail точка com
пред 15 години
Notice the red block at the beginning of this page... pdo_oci is HIGHLY experimental.

Even though it is under dev from 2004, it lakes today support for things that _do_ matters :
 - bind a varchar2 of 3500 chars 
 - get selected metas
 - left join with blobs/clobs
 - etc.

For the story, since we use pdo_pgsql in our software, I thought it would be viable to use pdo_oci for running under Oracle. After a long battle, I finally won :

1) If requested driver has a non-experimental pdo version available, use it.
2) else (well, for pdo_oci at least), use an abstraction layer of your own.
3) you're done.

What I did in more details...

2 "main" classes for being compliant with "$obj instanceof PDO" or such :
 - class PhpDb extends PDO
 - class PhpDbStatement extends PDOStatement
2 "abstract" classes that defines what PDO actually does :
 - abstract class PhpDbAbstract
 - abstract class PhpDbAbstractStatement
And at last for each driver, 2 classes doing the abstraction :
 - class PhpDbDriverOracle extends PhpDbAbstract
 - class PhpDbDriverOracleStatement extends PhpDbAbstractStatement

"main" classes are accessed from your script, simply replace "new PDO" with "new PhpDb".
"abstract" classes are mainly there for the documentation :p
"driver" classes do the job in background, they are instances by the main classes.

My PhpDb will be in an open source project sooner or later, search google or mail me !
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.