Use PHP to call the database storage process! (Reprinted) I believe that my friends who use PHP under WIN32 found that WIN32 was still used. Use PHP to call the database storage process! Author: fox4000 yesterday, I saw a comrade-in-arms asking if the stored procedure can be called using php. I felt that it was okay. so I immediately started an experiment to call the stored procedure of the database using PHP!
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'
Directive |
Local Value |
Master Value |
';While (! $ Rs-> EOF ){$ I + = 1;$ Fld0 = $ rs-> Fields (0 );$ Fld1 = $ rs-> Fields (1 );$ Fld2 = $ rs-> Fields (2 );Print'
'; Print $ fld0-> value; Print'
|
'; Print $ fld1-> value; Print' |
';
Success! Author: fox4000 yesterday, I saw a comrade-in-arms asking if the stored procedure can be called using php. I felt that it was okay. so I immediately conducted an experiment... |