Oracle 8 Funktionen
Diese Funktionen gestatten den Zugriff auf Oracle7 und Oracle8 Datenbanken. Es wird hierbei das Oracle8 Call-Interface (OCI8) verwendet, welches installierte Oracle8 Client Bibliotheken (Libraries) benötigt.
Diese Schnittstelle ist flexibler als die Standard Oracle Funktionen. Es unterstützt Binding von localen und globalen PHP Variablen an Oracle Platzhalter und hat volle LOB,FILE und ROWID Unterstützung und gestattet dem Benutzer die Verwendung von Variablendefines.
Vor der Benutzung dieser Erweiterung sollten Sie sicherstellen die folgenden Umgebungsvariablen für den Webserveruser VOR dem Start des Webservers gesetzt zu haben.
- ORACLE_HOME
- ORACLE_SID
- LD_PRELOAD
- LD_LIBRARY_PATH
- NLS_LANG
- ORA_NLS33
Nachdem Sie die Umgebungsvariablen festgelegt haben, stellen Sie sicher, das die Dateien im ORACLE_HOME/network/admin für den Webserver lesbar sind.
Hinweis: Wenn der Webserver abstürzt nach dem Start, oder nicht startet Überprüfen Sie, ob der Apache gegen -lpthread gelink ist:
# ldd /www/apache/bin/httpd libpthread.so.0 => /lib/libpthread.so.0 (0x4001c000) libm.so.6 => /lib/libm.so.6 (0x4002f000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x4004c000) libdl.so.2 => /lib/libdl.so.2 (0x4007a000) libc.so.6 => /lib/libc.so.6 (0x4007e000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
Wenn libpthread hier nicht gelistet ist, dann muss der Webserver neu übersetzt werden:
# cd /usr/src/apache_1.3.xx # make clean # LIBS=-lpthread ./config.status # make # make install
Example#1 OCI Hinweise
<?php
// by sergo@bacup.ru
// Die Option OCI_DEFAULT führt die Anweisung in einer Transaktion aus
OCIExecute($stmt, OCI_DEFAULT);
// for retrieve data use (after fetch):
$result = OCIResult($stmt, $n);
if (is_object ($result)) $result = $result->load();
// For INSERT or UPDATE statement use:
$sql = "insert into table (field1, field2) values (field1 = 'value',
field2 = empty_clob()) returning field2 into :field2";
OCIParse($conn, $sql);
$clob = OCINewDescriptor($conn, OCI_D_LOB);
OCIBindByName ($stmt, ":field2", &$clob, -1, OCI_B_CLOB);
OCIExecute($stmt, OCI_DEFAULT);
$clob->save ("some text");
OCICommit($conn);
?>
Man kann auf Stored Procedures auf einfache Weise zugreifen.
Example#2 Stored Procedures benutzen
<?php
// by webmaster@remoterealty.com
$sth = OCIParse ( $dbh, "begin sp_newaddress( :address_id, '$firstname',
'$lastname', '$company', '$address1', '$address2', '$city', '$state',
'$postalcode', '$country', :error_code );end;" );
// This calls stored procedure sp_newaddress, with :address_id being an
// in/out variable and :error_code being an out variable.
// Then you do the binding:
OCIBindByName ( $sth, ":address_id", $addr_id, 10 );
OCIBindByName ( $sth, ":error_code", $errorcode, 10 );
OCIExecute ( $sth );
?>
Inhaltsverzeichnis
- oci_bind_array_by_name — Bindet ein PHP-Array namentlich an ein Oracle-PL/SQL-Array
- oci_bind_by_name — Bindet eine PHP-Variable an einen Oracle Platzhalter
- oci_cancel — Bricht das Lesen eines Zeigers ab.
- oci_close — Schliesst eine Oracle-Verbindung
- OCI-Collection->append — Hängt das Element an die Sammlung
- OCI-Collection->assign — Weisst einen Wert aus einer anderen existierenden Sammlung einer Sammlung zu
- OCI-Collection->assignElem — Weisst einem Element in der Sammlung einen Wert zu
- OCI-Collection->free — Gibt die verknüpften Ressources eines Sammelobjekts frei
- OCI-Collection->getElem — Gibt den Wert des Element zurück
- OCI-Collection->max — Liefert die maximale Anzahl Elemente in einer Sammlung
- OCI-Collection->size — Liefert die Größe der Sammlung
- OCI-Collection->trim — Stutzt Element am Ende einer Sammlung
- oci_commit — Commits outstanding statements
- oci_connect — Establishes a connection to the Oracle server
- oci_define_by_name — Uses a PHP variable for the define-step during a SELECT
- oci_error — Liefert den letzten Fehler
- oci_execute — Executes a statement
- oci_fetch_all — Holt alle Reihen der Ergebnisdaten in ein Array
- oci_fetch_array — Liefert die nächste Zeile der Ergebnisdaten als assoziatives und/oder numerisches Array
- oci_fetch_assoc — Liefert die nächste Zeile der Ergebnisdaten als assoziatives Array
- oci_fetch_object — Liefert die nächste Zeile der Ergebnisdaten als Objekt
- oci_fetch_row — Liefert die nächste Zeile der Ergebnisdaten als numerisches Array
- oci_fetch — Holt die nächste Reihe in den Ergebnispuffer
- oci_field_is_null — Checks if the field is NULL
- oci_field_name — Returns the name of a field from the statement
- oci_field_precision — Tell the precision of a field
- oci_field_scale — Tell the scale of the field
- oci_field_size — Returns field's size
- oci_field_type_raw — Tell the raw Oracle data type of the field
- oci_field_type — Returns field's data type
- oci_free_statement — Gibt alle verknüpften Ressourcen eines Statements oder Zeigers frei.
- oci_internal_debug — Enables or disables internal debug output
- OCI-Lob->append — Appends data from the large object to another large object
- OCI-Lob->close — Closes LOB descriptor
- oci_lob_copy — Copies large object
- OCI-Lob->eof — Tests for end-of-file on a large object's descriptor
- OCI-Lob->erase — Erases a specified portion of the internal LOB data
- OCI-Lob->export — Exports LOB's contents to a file
- OCI-Lob->flush — Flushes/writes buffer of the LOB to the server
- OCI-Lob->free — Frees resources associated with the LOB descriptor
- OCI-Lob->getBuffering — Returns current state of buffering for the large object
- OCI-Lob->import — Imports file data to the LOB
- oci_lob_is_equal — Compares two LOB/FILE locators for equality
- OCI-Lob->load — Returns large object's contents
- OCI-Lob->read — Reads part of the large object
- OCI-Lob->rewind — Moves the internal pointer to the beginning of the large object
- OCI-Lob->save — Saves data to the large object
- OCI-Lob->saveFile — Alias von oci_lob_import
- OCI-Lob->seek — Sets the internal pointer of the large object
- OCI-Lob->setBuffering — Changes current state of buffering for the large object
- OCI-Lob->size — Returns size of large object
- OCI-Lob->tell — Returns current position of internal pointer of large object
- OCI-Lob->truncate — Truncates large object
- OCI-Lob->write — Writes data to the large object
- OCI-Lob->writeTemporary — Writes temporary large object
- OCI-Lob->writeToFile — Alias von oci_lob_export
- oci_new_collection — Allocates new collection object
- oci_new_connect — Establishes a new connection to the Oracle server
- oci_new_cursor — Allocates and returns a new cursor (statement handle)
- oci_new_descriptor — Initializes a new empty LOB or FILE descriptor
- oci_num_fields — Returns the number of result columns in a statement
- oci_num_rows — Returns number of rows affected during statement execution
- oci_parse — Prepares Oracle statement for execution
- oci_password_change — Changes password of Oracle's user
- oci_pconnect — Connect to an Oracle database using a persistent connection
- oci_result — Returns field's value from the fetched row
- oci_rollback — Rolls back outstanding transaction
- oci_server_version — Returns server version
- oci_set_prefetch — Sets number of rows to be prefetched
- oci_statement_type — Returns the type of an OCI statement
- ocibindbyname — Alias von oci_bind_by_name
- ocicancel — Alias von oci_cancel
- ocicloselob — Alias von
- ocicollappend — Alias von
- ocicollassign — Alias von
- ocicollassignelem — Alias von
- ocicollgetelem — Alias von
- ocicollmax — Alias von
- ocicollsize — Alias von
- ocicolltrim — Alias von
- ocicolumnisnull — Alias von oci_field_is_null
- ocicolumnname — Alias von oci_field_name
- ocicolumnprecision — Alias von oci_field_precision
- ocicolumnscale — Alias von oci_field_scale
- ocicolumnsize — Alias von oci_field_size
- ocicolumntype — Alias von oci_field_type
- ocicolumntyperaw — Alias von oci_field_type_raw
- ocicommit — Alias von oci_commit
- ocidefinebyname — Alias von oci_define_by_name
- ocierror — Alias von oci_error
- ociexecute — Alias von oci_execute
- ocifetch — Alias von oci_fetch
- ocifetchinto — Fetcht die nächste Zeile des Ergebnisses in ein Array (deprecated!)
- ocifetchstatement — Alias von oci_fetch_all
- ocifreecollection — Alias von
- ocifreecursor — Alias von oci_free_statement
- ocifreedesc — Alias von
- ocifreestatement — Alias von oci_free_statement
- ociinternaldebug — Alias von oci_internal_debug
- ociloadlob — Alias von
- ocilogoff — Alias von oci_close
- ocilogon — Alias von oci_connect
- ocinewcollection — Alias von oci_new_collection
- ocinewcursor — Alias von oci_new_cursor
- ocinewdescriptor — Alias von oci_new_descriptor
- ocinlogon — Alias von oci_new_connect
- ocinumcols — Alias von oci_num_fields
- ociparse — Alias von oci_parse
- ociplogon — Alias von oci_pconnect
- ociresult — Alias von oci_result
- ocirollback — Alias von oci_rollback
- ocirowcount — Alias von oci_num_rows
- ocisavelob — Alias von
- ocisavelobfile — Alias von
- ociserverversion — Alias von oci_server_version
- ocisetprefetch — Alias von oci_set_prefetch
- ocistatementtype — Alias von oci_statement_type
- ociwritelobtofile — Alias von
- ociwritetemporarylob — Alias von