Use PHP to call the database storage process! (reprint) believe that you in the WIN32 with PHP friends found that the original use of WIN32 also have this benefit oh. ...
Process | data | Database use PHP to call the database storage process!
Author: fox4000
Yesterday, saw a comrade asked if you can use PHP to call the storage process, the feeling should be can, so, immediately carried out the experiment, very successful! It's so unexpected! So, write it out, for everyone's reference!
As you know, stored procedures are on the server side of a script program, the execution is fast, but it also has a disadvantage, is dependent on a fixed database, transplant is not good!
My last article, mentioned that the use of COM components can access ADO and related components, whether built or 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 talk 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 in this study, had to take 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;
Note that your server must be turned on! In addition, the name of the stored procedure cannot be written incorrectly. Otherwise it will be a fatal error, and, you do not know where the error is, this is the PHP file on the bad treatment, but I believe it will be improved.
I have to learn PHP for a long time, but found that 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 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.