PHP joins Oracle to insert multiple images

Source: Internet
Author: User
Tags joins

PHP connection to the Oracle database, its query, update, delete data and similar to MySQL, but add data, especially the picture of the time is very different, which involves the creation of a Blob object, with the Blod object to save the PHP image, the following is the time when inserting more than one picture of the wording, Directly on the code:

$conn= Oci_connect (' Rgsuser ', ' mycompany ', ' (DESCRIPTION = (Address_list = (address = (PROTOCOL = TCP) (HOST = **.**.**.** (IP address) ) (PORT = 1521)) (Connect_data = (service_name = ORCL))) ', ' UTF8 '); $sql=$sql." ID, ";$value=$value." Sys_guid (), "; $sql=$sql." LSH, ";$value=$value. ": Lsh". ","; $sql=$sql." Verfytype, ";$value=$value. ": Verfytype". ","; $sql=$sql." Identificationno, ";$value=$value. ": id". ","; $sql=$sql." Realname, ";$value=$value. ": Realname". ","; $sql=$sql." PHONE, ";$value=$value. ":p hone". ","; $sql=$sql." Binddrivelicense, ";if($dabh!=NULL) {$value=$value." 1, "; }Else{$value=$value." 0, ";} $sql=$sql." Picdataidentiface, ";$value=$value." Empty_blob (), "; $sql=$sql." Picdataidentifacewatermark, ";$value=$value." Empty_blob (), "; $sql=$sql." Picdataidentiback, ";$value=$value." Empty_blob (), "; $sql=$sql." Picdataidentibackwatermark, ";$value=$value." Empty_blob (), "; $sql=$sql." Picdataidentiperson, ";$value=$value." Empty_blob (), "; $sql=$sql." Picdataidentipersonwatermark, ";$value=$value." Empty_blob (), "; $sql=$sql." Islock) VALUES (";$value=$value." 0 ".") ";//It is important here that the field that holds the picture specifies the corresponding label $sql=$sql.$value." Returning Picdataidentiface,picdataidentifacewatermark,picdataidentiback,picdataidentibackwatermark, Picdataidentiperson,picdataidentipersonwatermark,picdatavehiclelic,picdatavehiclelicwatermark into: Picdataidentiface,:P Icdataidentifacewatermark,:P icdataidentiback,:P Icdataidentibackwatermark,: Picdataidentiperson,:P Icdataidentipersonwatermark,:P icdatavehiclelic,:P Icdatavehiclelicwatermark ";/*The above stitching statement is more complex, following the concatenation of the result string (1072) "INSERT into T_rrgu_submition (id,lsh,verfytype,identificationno,realname,phone , Binddrivelicense,picdataidentiface,picdataidentifacewatermark,picdataidentiback,picdataidentibackwatermark, Picdataidentiperson,picdataidentipersonwatermark,dabh,carinfohphm,carinfohpzl,carinfofdjh,picdatavehiclelic, Picdatavehiclelicwatermark,created,sourcetype,sourceapp,judgestate,publishreulttype,publishstate,querypassword , Contactaddress,islock) VALUES (Sys_guid (),: Lsh,:verfytype,:id,:realname,:p Hone,1,empty_blob (), Empty_blob (), Empty_blob (), Empty_blob (), Empty_blob (), Empty_blob (),:d Abh,:hphm,:hpzl,:fdjh,empty_blob (), Empty_blob (), Sysdate, : targetsourcetype,:sourcetype,0,-1,0,:mm,:contactaddress,0) Returning Picdataidentiface, Picdataidentifacewatermark,picdataidentiback,picdataidentibackwatermark,picdataidentiperson, Picdataidentipersonwatermark,picdatavehiclelic,picdatavehiclelicwatermark into:P icdataidentiface,: Picdataidentifacewatermark,:P icdataidentiback,:P IcdataidentibacKwatermark,:P Icdataidentiperson,:P Icdataidentipersonwatermark,:P icdatavehiclelic,:P Icdatavehiclelicwatermark " *///creating BLOB objects and binding data            $stid= Oci_parse ($conn,$sql); $PICDATAIDENTIFACEblob= Oci_new_descriptor ($conn,Oci_d_lob); $PICDATAIDENTIFACEWATERMARKblob= Oci_new_descriptor ($conn,Oci_d_lob); $PICDATAIDENTIBACKblob= Oci_new_descriptor ($conn,Oci_d_lob); $PICDATAIDENTIBACKWATERMARKblob= Oci_new_descriptor ($conn,Oci_d_lob); $PICDATAIDENTIPERSONblob= Oci_new_descriptor ($conn,Oci_d_lob); $PICDATAIDENTIPERSONWATERMARKblob= Oci_new_descriptor ($conn,Oci_d_lob); Oci_bind_by_name ($stid, ': Lsh ',$lsh); Oci_bind_by_name ($stid, ': Verfytype ',$verfytype); Oci_bind_by_name ($stid, ': Id ',$id); Oci_bind_by_name ($stid, ': Realname ',$realname); Oci_bind_by_name ($stid, ':p hone ',$phone); Oci_bind_by_name ($stid, ': Targetsourcetype ',$targetSourcetype); Oci_bind_by_name ($stid, ': SourceType ',$sourcetype); Oci_bind_by_name ($stid, ': mm ',$mm); Oci_bind_by_name ($stid, ': Contactaddress ',$contactAddress);//EXECUTE StatementOci_execute ($stid,oci_default);//Blob object saves the corresponding picture dataif($PICDATAIDENTIFACEblob->save (Base64_decode($picIdentiFace)) &&$PICDATAIDENTIFACEWATERMARKblob->save (Base64_decode($picIdentiFaceWaterRemark)) &&$PICDATAIDENTIBACKblob->save (Base64_decode($picIdentiBack)) &&$PICDATAIDENTIBACKWATERMARKblob->save (Base64_decode($picIdentiBackWaterRemark)) &&$PICDATAIDENTIPERSONblob->save (Base64_decode($picIdentiWithUser)) &&$PICDATAIDENTIPERSONWATERMARKblob->save (Base64_decode($picIdentiWithUserWaterRemark))) {                  //On success, commit the transaction//Var_dump ("data is correctly added to the database");Oci_commit ($conn); Oci_free_statement ($stid); Oci_close ($conn); }Else{                        $error=Oci_error (); Echo $error; Oci_rollback ($conn); Oci_free_statement ($stid); Oci_close ($conn); $err= "Internal Error! ";}

PHP joins Oracle to insert multiple images

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.