Home > Backend Development > PHP Tutorial > Use PHP to call the stored procedure of the database! (Reprinted) I believe that friends who use PHP under WIN32 will find that there is a _PHP tutorial when using WIN32

Use PHP to call the stored procedure of the database! (Reprinted) I believe that friends who use PHP under WIN32 will find that there is a _PHP tutorial when using WIN32

WBOY
Release: 2016-07-13 16:58:31
Original
880 people have browsed it

Use PHP to call the stored procedure of the database!
Author: fox4000
Yesterday, I saw a comrade asking if he could use php to call the stored procedure. I felt that it should be possible, so I immediately conducted the experiment and it was very successful! Very unexpected! Therefore, write it down for everyone’s reference!
As we all know, a stored procedure is a script program on the server side, which is very fast to execute, but it also has a disadvantage, that is, it relies on a fixed database and has poor portability!
My last article mentioned that you can use COM components to access ado and related components. Whether you build it yourself or bring it with the system, you can expand the functions of the system, but now PHP does not support dcom/com+, but I believe it should be supported in the next version.
Without further ado, let’s try it right away.
The following is a simple storage procedure of mine
CREATE PROCEDURE [sp_mystoreprocedure] AS
select companyname, contactname, city from customers
Actually, you can also write more complex ones, but unfortunately I have to research this It’s not deep, so I have to keep it simple!
The following 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 '





';
while (!$rs->EOF) {
$i += 1;
$fld0 = $rs->Fields(0);
$fld1 = $rs->Fields(1);
$fld2 = $rs->Fields(2);
print '

Directive Local Value< ;/th>
Master Value
';
print $fld0->value;
print '

';
print $fld1->value;
print '
';

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631432.htmlTechArticleUse PHP to call the stored procedure of the database! Author: fox4000 Yesterday, I saw a comrade asking if the stored procedure could be called using php. I felt it should be possible, so I immediately conducted an experiment...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template