I was getting similar errors when trying to use PDO from using sqlsrv before and wanted to document the process to a solution somewhere so that anyone with the same problem can hopefully find this solution.
Converting old sql_srv code to use PDO in PHP. The original code:
$params = array(array($date, SQLSRV_PARAM_IN),array($location, SQLSRV_PARAM_IN),array(3, SQLSRV_PARAM_IN));
$result = sqlsrv_query($sqldb, "{call Some_Stored_Procedure ( @base_date=?,@location=?,@plusdays=? )}", $params);
New code V1:
$q = "{call Some_Stored_Procedure ( @base_date=?,@location=?,@plusdays=? )}";
$params = array(array($date, SQLSRV_PARAM_IN),array($location, SQLSRV_PARAM_IN),array(3, SQLSRV_PARAM_IN));
$stmt = $CONN->prepare($q);
$stmt->execute($params);
Which threw: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Could not find stored procedure 'Some_Stored_Procedure'.'
This error was resolved by specifying the database as in:
$q = "{call Database.dbo.Some_Stored_Procedure ( @base_date=?,@location=?,@plusdays=? )}";
$params = array(array($date, SQLSRV_PARAM_IN),array($location, SQLSRV_PARAM_IN),array(3, SQLSRV_PARAM_IN));
$stmt = $CONN->prepare($q);
$stmt->execute($params);
But this introduced a new error and is the reason this question exists: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Error converting data type nvarchar to datetime.'
Trying to solve this error led to many other errors(none of which point to the actual problem!) including the authors' Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '@P1'.'
The eventual solution(same as authors):
$stmt = $CONN->prepare("Exec Database.dbo.Some_Stored_Procedure ?, ?, 3");
$stmt->execute(array($date, $location));
The difference(that I feel the author didn't stress) is in the format of calling the stored procedure. Instead of:
CALL Some_Stored_Procedure(Param1, Param2, ...);
It is
EXEC Some_Stored_Procedure Param1, Param2, ...;
Use EXEC instead of CALL(there are some differences) and do not use parenthesizes around your parameters.