Put your head on my shoulder use PHP to call the database storage process!

Source: Internet
Author: User
Use PHP to call the database storage process!
Author: fox4000
Yesterday, see a comrade asked if you can use PHP to call the storage process, the feeling should be able to, so, immediately carried out the experiment, very successful! It was a very unexpected surprise to me! Therefore, write out, for everyone to reference!
As you know, the stored procedure is a script on the server side, the execution speed is very fast, but it also has a disadvantage, is to rely on a fixed database, portability is not good!
My last article, mentioned that with COM components can access ADO and related components, whether it is built or the system with, can extend the functionality of the system, but now PHP does not support dcom/com+, but believe that its next version should be supported.
Don't say so much, let's try it right away.
Here's a simple storage process for me.
CREATE PROCEDURE [Sp_mystoreprocedure] As
Select CompanyName, ContactName, city from customers
In fact, can also write more complex, but I am not deep on this study, had to take the simple!
Here 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; $fld 0 = $rs->fields (0); $fld 1 = $rs->fields (1); $FLD 2 = $rs->fields (2); print ' '; $rs->movenext (); } print '
Directive Local Value Master Value
';
Print $FLD 0->value;
print '

';
Print $FLD 1->value;
print '
';
Print $FLD 2->value;
print '
';
$rs->close ();
?>
Note that your server must be turned on! In addition, the name of the stored procedure cannot be written incorrectly. Otherwise it will be out of the fatal error, and, you do not know the error is there, this is the PHP file bad for error handling, but I believe it will be improved later.
I have been learning PHP for a long time, but found to really use it, not so easy, but it is also beyond my imagination, some things really wonderful, really, do not know, a use really wonderful!

The above describes the put your head on my shoulder using PHP to call the database storage process! , including put your head on my shoulder, I want to be interested in PHP tutorial friends helpful.

  • 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.