How to call Stored Procedures from SQL Server using php

Hi,
In C# I can write a quick function to connect to an SQL server DB and retrieve a value/s like this:

SqlCommand _Command = new SqlCommand("SomeStoredProc", new SqlConnection(_sqlConnectionString));
				_Command.CommandType = CommandType.StoredProcedure;
				_Command.Parameters.AddWithValue("@Date", DateTime.Today);
				_Command.Connection.Open();
				SqlDataReader myReader = _Command.ExecuteReader(CommandBehavior.CloseConnection);
				if (myReader.HasRows)
				{
					while (myReader.Read())
					{
						_Files.Add(myReader["FileName"].ToString());
					}
					myReader.Close();
				}

My question is:
How can I write a function like this in PHP?

Use PDO.

^ Yes. You may need to install some dll files and edit the ini file, but it should be doable

Preferred driver:
http://php.net/manual/en/ref.pdo-sqlsrv.php

second choice:
http://php.net/manual/en/ref.pdo-odbc.php

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.