PHP 5 and coding for a stored procedure

Hello folks,

   I have a MS Sql stored procedure that inserts a record into a table and returns the Primary Key (as  scope-identity) as output.
It works very well using classic asp but I need to convert it PHP 5 coding.
  The examples I find use mssql_bind and so forth.
I need a good, understandable example that use sqlsrv_ commands. I understand about parameters etc but I do not know the exact syntax and structure of creating the code other than opening a connection etc.
I could just  insert a record just as well but the requirement is that I must have primary key returned to me  of the record that I just inserted, which is what scope_identity is about..and I am not sure how to that either..sigh
 Could someone point me in the right direction on how to code for a stored procedure that returns the scope identity? Or inserting a record and returning its primary key?
It would be appreciated..
OverthereAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LajuanTaylorCommented:
@Overthere - Please take a look at the following sample application provided by Microsoft that leverages the (SQLSRV Driver) for PHP.

Valid link as of: 11/20/2015 https://msdn.microsoft.com/en-us/library/cc296196(v=sql.105).aspx

The example application uses the SQL AdventureWorks database provided by Microsoft with PHP code to allow a user to search for products by entering a keyword, see reviews for a selected product, write a review for a selected product, and upload an image for a selected product.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dave BaldwinFixer of ProblemsCommented:
The SQL statements should be the same since they are run by the SQL Server and not by PHP (or even ASP).  ??
LajuanTaylorCommented:
@Overthere - I attached the sample code from Microsoft that leverages PHP sqlsrv_ commands.
adventureworks_demo.php.txt
photo.php.txt
LajuanTaylorCommented:
@Overthere - A second example from Microsoft that uses AdventureWorks database. It first drops the stored procedure if it doesen't exist, then recreates the stored procedure. The sample then calls the stored proc and returns a result using PHP. See attached file.
call_stored_procedure_from_php.php.txt
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.