|
oci_connect
Establishes a connection to the Oracle server
(PHP 5, PECL oci8:1.1-1.2.4)
Example 1637. oci_connect() example<?php
Examples ( Source code ) » oci_connect
Related Examples ( Source code ) » oci_connect Examples ( Source code ) » Connecting to Oracle Using OCI8 Examples ( Source code ) » Closing Oracle Connections Examples ( Source code ) » A basic query in OCI8 Examples ( Source code ) » A basic example to fetch results oci_fetch_array Examples ( Source code ) » Executing SQL Statements With OCI8 Transactions Examples ( Source code ) » Handling OCI8 Errors Examples ( Source code ) » Creating PL/SQL Procedures in PHP Examples ( Source code ) » Calling PL/SQL Procedures and Functions Examples ( Source code ) » PL/SQL Errors in PHP Examples ( Source code ) » Oracle Collections in PHP Examples ( Source code ) » Array Binding and PL/SQL Bulk Processing Examples ( Source code ) » Using PL/SQL Types in PHP Examples ( Source code ) » Getting Output with DBMS_OUTPUT Examples ( Source code ) » Using Large Objects in OCI8 Examples ( Source code ) » Working with BFILEs Code Examples / Notes » oci_connectsebastien.barbieri _at_ gmail dot com
When you are using Oracle 9.2+ I would say that you MUST use the CHARSET parameter. Of course, you will not notice it until there is accented character... so just specify it and you will avoid a big headache. So for example here is our Oracle internal conf: select * from nls_database_parameters; PARAMETER VALUE ------------------------------ ---------------------------------------- ⦠NLS_LANGUAGE AMERICAN NLS_TERRITORY AMERICA NLS_ISO_CURRENCY AMERICA NLS_CHARACTERSET WE8ISO8859P15 ⦠And there our oci_connect call: $dbch=ocilogon($user,$pass,$connectString,"WE8ISO8859P15"); Without that, you will get question mark (inversed), squares⦠instead of most accented character. Donât forget to use that for writing as well as for reading. a01b02_no_spam
Using tnsnames.ora Apache 2 php 5.0.5 Oracle 10 IstantClient PHP half of times return this error: OCISessionBegin: ORA-24327: need explicit attach before authenticating a user in ... In Oracle manual I find: ORA-24327 need explicit attach before authenticating a user Cause: A server context must be initialized before creating a session. Action: Create and initialize a server handle. I resolved using Easy Connect Naming Method. Notice of this problem in bug#29779. --- Best Regards, Domenico domenico a01b20_nospam_
This note is an addendum to note#58378 Seems to be a good workaround set the oracle_home and/instead of the tns_admin. tnsnames.ora must to be located in $ORACLE_HOME/network/admin and in $TNS_ADMIN/ (if you use it) --- Best Regards, Domenico chris
Our tnsnames.ora uses the SERVICE_NAME=mydb - which for some reason wont work with PHP even though it works fine with tnsping. Using SID=mydb worked and a connection was established.
andrei
lost oracle connection. need restart apache? Temporarely you can prevent 'connection lost' by using folowing script (use it at your own risk): <?php $rnum=rand(0,99999999); $dbcon = oci_new_connect('XXXXX', 'XXXXXX', ' (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = XXX.XXX.XXX.XXX) (PORT = 1521) (HASH = '.$rnum.') ) (CONNECT_DATA =(SID = XXX)) ) '); ?> greatval
For use PHPv5 functions in PHPv4 i use simple script: <?php $funcs=array( 'oci_connect'=>'OCILogon', 'oci_parse'=>'OCIParse', 'oci_execute'=>'OCIExecute', 'oci_fetch'=>'OCIFetch', 'oci_num_fields'=>'OCINumCols', 'oci_field_name'=>'OCIColumnName', 'oci_result'=>'OCIResult', 'oci_free_statement'=>'OCIFreeStatement', ); // yoy can add yours pairs of funcs. foreach ($funcs as $k=>$v) { if (!function_exists($k)) { $arg_string='$p0'; for ($i=1;$i<20;$i++) { $arg_string.=',$p'.$i; } eval ('function '.$k.' () { list('.$arg_string.')=func_get_args(); return '.$v.'('.$arg_string.'); } '); } } ?> simple, but it work. :-) |
Change Languageoci_bind_array_by_name oci_bind_by_name oci_cancel oci_close OCI-Collection->append OCI-Collection->assign OCI-Collection->assignElem OCI-Collection->free OCI-Collection->getElem OCI-Collection->max OCI-Collection->size OCI-Collection->trim oci_commit oci_connect oci_define_by_name oci_error oci_execute oci_fetch_all oci_fetch_array oci_fetch_assoc oci_fetch_object oci_fetch_row oci_fetch oci_field_is_null oci_field_name oci_field_precision oci_field_scale oci_field_size oci_field_type_raw oci_field_type oci_free_statement oci_internal_debug OCI-Lob->append OCI-Lob->close oci_lob_copy OCI-Lob->eof OCI-Lob->erase OCI-Lob->export OCI-Lob->flush OCI-Lob->free OCI-Lob->getBuffering OCI-Lob->import oci_lob_is_equal OCI-Lob->load OCI-Lob->read OCI-Lob->rewind OCI-Lob->save OCI-Lob->saveFile OCI-Lob->seek OCI-Lob->setBuffering OCI-Lob->size OCI-Lob->tell OCI-Lob->truncate OCI-Lob->write OCI-Lob->writeTemporary OCI-Lob->writeToFile oci_new_collection oci_new_connect oci_new_cursor oci_new_descriptor oci_num_fields oci_num_rows oci_parse oci_password_change oci_pconnect oci_result oci_rollback oci_server_version oci_set_prefetch oci_statement_type ocibindbyname ocicancel ocicloselob ocicollappend ocicollassign ocicollassignelem ocicollgetelem ocicollmax ocicollsize ocicolltrim ocicolumnisnull ocicolumnname ocicolumnprecision ocicolumnscale ocicolumnsize ocicolumntype ocicolumntyperaw ocicommit ocidefinebyname ocierror ociexecute ocifetch ocifetchinto ocifetchstatement ocifreecollection ocifreecursor ocifreedesc ocifreestatement ociinternaldebug ociloadlob ocilogoff ocilogon ocinewcollection ocinewcursor ocinewdescriptor ocinlogon ocinumcols ociparse ociplogon ociresult ocirollback ocirowcount ocisavelob ocisavelobfile ociserverversion ocisetprefetch ocistatementtype ociwritelobtofile ociwritetemporarylob |