Request: Please show me a working example of how to retrieve(in an array?) returned rows from a Stored Procedure on a MSSQL server using Zend Framework and passing parameters to the stored procedure.
Explanation: I can't find anything in the ZF docs about how to execute SP on MSSQL servers. I'm aware that it is possible via plain PHP. However, since my project uses ZF, I'd like not to have to have extra code to open a connection to the server, etc. etc. Digging through the ZF code I see things like "bindParam" and "execute" and "prepare". However I have no idea how these work or what I am to do with them. So of course a bit of explanation to the requested example code would be very nice.
I'm using Zend_Db_Adapter_Pdo_Mssql by the way.
Thanks!
Here's what I did using the php5-sybase driver on Debian. This is plain PHP, so probably that's not what you want, but maybe it will give you some leads. Even doing this via plain PHP was surprisingly tricky for me!
NOTE: That "vm8" thing cames from a file called /etc/freetds/freetds.conf, and nothing would work until I created the "vm8" alias in there.
DIDN'T WORK (although non-SP stuff was fine!?!?!).
But after I created "vm8" section (my own name) inside /etc/freetds/freetds.conf like so....
Then my stored procedures worked once I changed the connect hostname to use that section heading:
Whew.
For reference here was my SP:
i am sorry to say you can't run stored Procedure in current state of ZF AFAIK why ..... take a look here
Source : http://www.phparch.com/2010/06/25/zend-db-2-0-kicks-off/
update : after i had answered you , i got this link from google , and i think it worth mentioning
http://zend-framework-community.634137.n4.nabble.com/mssql-pdo-lastInsertID-with-a-stored-procedure-td672685.html
When you said that there is no result from MS SQL STORED PROC - it is not correct (if it returns any value of course).
But it also returns inserted, updated or deleted applied counts if there are such operations.
And if you make a temp table at the beginning of the proc - try to guess what you would get.
So you need to insert SET NOCOUNT ONN at the begging of the proc to do not return such results.
Ok, after spendig a couple hours digging the problem I came up with the following code - I do not use pure PHP, still using the framework accordingly. Seens to be fine and run ok, I am even getting also the resultset back! Hope it helps:
Doesn't something like this work?