Re: [Phplib-users] Oracle usage
Brought to you by:
nhruby,
richardarcher
From: Mike G. <Mik...@sa...> - 2001-09-24 14:53:09
|
Eric, About a year ago I ran into a problem with Oracle and PHPLib. The patch that I came up with after discussions with those on this list was posted to the list on 12 October 2000. (I will paste the same post to the end of this for your convenience.) Other than that I had no problems. The project then died when the firm for which I was doing the work declared bankruptcy in January of 2001. This was after what I had implemented had been well tested on a prototype basis, but before the web site went into full production. I can't remark, therefore, on whether there were any problems in the longer term or under high load conditions. The text of what I posted on 12 October 2000: "Well, with the suggestions here and those posted on the PHP manual pages for OCI8 (especially those of jc...@id... on the page http://www.php.net/manual/function.ocinewdescriptor.php), I've come up with something that seems to be working. I thought it would be good to post it here in case someone else can use it ...and to get your feedback. "I've extended the OCI8 DB_Sql class (db_oci8.inc,v 1.4 2000/07/12 18:22:34) by revising its function query to read: function query($Query_String, $bind_var = '', $bind_val = '') { /* No empty queries, please, since PHP4 chokes on them. */ if ($Query_String == "") /* The empty query string is passed on from the constructor, * when calling the class without a query, e.g. in situations * like these: '$db = new DB_Sql_Subclass;' */ return 0; $this->connect(); if ($bind_var){ $clob = OCINewDescriptor($this->Link_ID, OCI_D_LOB); $Query_String .= " returning $bind_var into :the_blob"; } $this->Parse=OCIParse($this->Link_ID,$Query_String); if(!$this->Parse) { $this->Error=OCIError($this->Parse); } else { if ($bind_var) { OCIBindByName($this->Parse, ':the_blob', &$clob, -1, OCI_B_CLOB); OCIExecute($this->Parse, OCI_DEFAULT); if($clob->save($bind_val)){ OCICommit($this->Link_ID); }else{ $this->Error = "Couldn't insert CLOB into database."; } OCIFreeDesc($clob); } else { OCIExecute($this->Parse); } $this->Error=OCIError($this->Parse); } $this->Row=0; if($this->Debug) { printf("Debug: query = %s<br>\n", $Query_String); } if ($this->Error["code"]!=1403 && $this->Error["code"]!=0 && $this->sqoe) echo "<BR><FONT color=red><B>".$this->Error["message"]."<BR>Query:\"$Query_String\"</B></FONT>"; return $this->Parse; } "This seems to be working. "It has three shortcomings that I am aware of: "1) It only allows for one type of 'bind' variable: CLOB. "2) It only allows for one column to be a 'bind' variable "3) One must be sure that the $Query_String is has the correct form for this usage: '$bind_var' in $Query_String must be paired with 'EMPTY_CLOB(),' not its value: $bind_val. "I can think of ways to deal with each of these, but not in the time I have available to get the present project going. And this seems to be doing the job for Inserts and Updates. "I find it a bit puzzling that Selects seem to work all right without using this approach. I.e. I'm just using a straight SQL select, without any 'binds.' And I seem to be having no trouble retrieving the data. ..." Cheers! Mike Green Eric McKeown wrote: > Hi folks, > > Just wondering how many of you out there have used PHP/PHPLIB with > Oracle and whether you've had good experiences. I've been asked to > evaluate the possibility of moving an application that is currently > PHP/PHPLIB/Sybase to an Oracle backend, and if you have any gotchas to > share, I would greatly appreciate the info. > > Thanks, > > Eric > > _______________________________________________ > Phplib-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phplib-users -- Mike Green SaeSolved:: http://www.saesolved.com http://www.everypeople.net http://www.sitewidgets.com http://www.widgetchuck.com |