Use PHP to call the database storage process! I believe that my friends who use PHP under WIN32 found that WIN32 was used and

Source: Internet
Author: User

Use PHP to call the database storage process!
Author: fox4000
Yesterday, I saw a comrade-in-arms asking if I could use php to call the storage process. I thought it was okay. So I started the experiment right away and it was very successful! Beyond my expectation! Therefore, write it for your reference!
As you know, the stored procedure is a script program on the server, which runs very quickly. However, it also has a disadvantage: It depends on a fixed database and has poor portability!
In my previous article, I mentioned that the com component can be used to access ado and related components. Both self-built and system-carried components can be used to expand the system functions, but now php does not support dcom/com +, but I believe its next version should support it.
Let's try it now.
Below is my simple storage process
Create procedure [sp_mystoreprocedure]
Select companyname, contactname, city from MERs
In fact, it can be complicated to write. Unfortunately, I did not have a deep research on this, so I had to take it easy!
Below is my PHP File
<?
Define ("OLEDB_CONNECTION_STRING ",
"Provider = SQLOLEDB; Data Source = zzb; Initial Catalog = Northwind; User ID = sa; Password = ");
$ Dbc = new COM ("ADODB. Connection ");
$ Dbc-> Open (OLEDB_CONNECTION_STRING );
$ Command = "sp_mystoreprocedure ";
$ Rs = $ dbc-> Execute ($ command); // Recordset
$ I = 0;
Echo '<table cellSpacing = "1" cellPadding = "3" width = "600" align = "center" bgColor = "#000000" border = "0">
<Tr vAlign = "bottom" bgColor = "# 9999cc">
<Th> Directive </th>
<Th> Local Value </th>
<Th> Master Value </th>
</Tr> ';
While (! $ Rs-> EOF ){
$ I + = 1;
$ Fld0 = $ rs-> Fields (0 );
$ Fld1 = $ rs-> Fields (1 );
$ Fld2 = $ rs-> Fields (2 );
Print '<tr vAlign = "baseline" bgColor = "# cccccc">
<Td bgColor = "# ccccff"> <B> ';
Print $ fld0-> value;
Print '</B> <br> </td>
<Td align = "middle"> ';
Print $ fld1-> value;
Print '</td> <td align = "middle"> ';

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.