Re: PEAR, oci8 and CLOBS

From: Date: Tue, 30 Oct 2001 10:50:55 +0000
Subject: Re: PEAR, oci8 and CLOBS
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-451@lists.php.net to get a copy of this message
Thanks for the replies. I have been using the OCINewDescriptor and OCIBindByName as you state below and these work OK. The problem being is that I am converting some code (namely PostNuke) to be usable on multiple databases. I know have a problem that when ever the code is working with CLOBS I have to go into the whole if(strcmp($dbtype), 'oci8) == 0) { //Do Oracle specific CLOB handling. } I've been looking through the Perl DBD::Oracle code and it seems like the Perl code handles CLOBS and LOBS without any problems. I was wondering weather the types of methods used in that code could be converted to PEAR? As the question was asked in the thread here is an example of how to insert data into a CLOB (This is only needed for >4000 chars). <CLOB CODE> //connect to your database $conn = OCILogon($dbuname, $dbpass, $dbhost); //well, first you have to create a descriptor $clob = OCINewDescriptor($conn, OCI_D_LOB); //setup your query $query = "INSERT INTO MY_TABLE (counter, clob_field) VALUES ($nextid, EMPTY_CLOB()) returning clob_field into :THE_CLOB"; //then parse your query $stmt = OCIParse($conn, $query); //then you have to bind :THE_CLOB to $clob OCIBindByName($stmt, ":THE_CLOB", &$clob, -1, OCI_B_CLOB); //then execute your query (OCI_DEFAULT flag is a *MUST HAVE*) OCIExecute($stmt, OCI_DEFAULT); //and save the information to the db via the descriptor $clob->save($clob_data); //then commit (again, *MUST HAVE*) OCICommit($stmt); //free your descriptor and statement handle OCIFreeDescriptor($clob); OCIFreeStatement($stmt); //Disconnect from db OCILogoff($conn); </CLOB CODE> On Tue, 30 Oct 2001, Graeme Merrall wrote: > There's prob not much in PEAR for doing this at the mo. I've briefly looked at > it but not got too far because I didnt' end up needing it. > As you'll know Paul to start talking to CLOBs you need to create a new > descriptor using OCINewDescriptor() then bind this descriptor to a variable > returned from a query using OCIBindByName(). You can then treat the variable > as an object and away you go. > I know that there have been additions of some lob functions to PHP but I've not > investigated them at all. > > I'm not sure how far along PEAR is with variable binding - I know there has > certainly been discussion on it but I certainly know that the descriptor stuff > is not implemented at all. > > I'm sure someone can tell us the status of binding columns? > > Cheers, > Graeme > ------------------------------------------------------------ Paul Edmondson, Software Engineer Yospace: Creating Value for Wireless 7 The Courtyard, High Street, Staines, UK, TW18 4DR Tel: +44 1784 466388 Fax: +44 1784 466387 http://www.yospace.com This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. Any unauthorised dissemination or copying of this email or its attachments, and any use or disclosure of any information contained in them, is strictly prohibited and may be illegal. If you have received the email in error please notify contracts@yospace.com and delete it from your system.

« previous php.pear.general (#451) next »