An oracle + PHP query example

Source: Internet
Author: User
An example of oracle + PHP query http://qdlover.yeah.net
An oracle + PHP query example
I didn't need php anymore, but a lot of friends asked me, so I made an example. for details about the function, please refer to the manual.
In fact, oracle functions are similar to others, but here it has an additional process to define output variables,
Anyone who has studied pl/SQL knows this (but I heard that only Tsinghua and Xi'an Jiaotong University use it as their websites ).
That is, OCIDefineByName ($ id, "ROWNUM", & $ rownum); corresponds to the rownum in the query,
The most important thing to note is that the field name must be in upper case during definition, because oracle does not recognize lower case letters.
The rest is almost the same. assign values, display, and close the cursor.
$ Conn = ocilogon ("gcxx", "gcxx", "server1 ");
$ Id = OCIParse ($ conn, "select rownum, gcdjbh, gcmc from zbgg ");
OCIDefineByName ($ id, "ROWNUM", & $ rownum );
OCIDefineByName ($ id, "GCDJBH", & $ gcdjbh );
OCIDefineByName ($ id, "GCMC", & $ gcmc );

OCIExecute ($ id );
$ I = 0;
While (OCIFetch ($ id )){

Echo "No.:". $ rownum ."
";
Echo "project registration no.:". $ gcdjbh ."
";
Echo "Project name:". $ gcmc ."
";
$ I ++;
If ($ I> 10) break;
}
OCIFreeStatement ($ id );
OCILogoff ($ conn );
?>

(Source: Viphot)

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.