Reputation: 9
We are executing a stored procedure against an MSSQL database with PHP.
When we hand build the stored procedure and execute it manually with Navicat we get the correct results.
When we build the query and execute it with PHP we get a different result.
Is there any way for us to PREVIEW the stored procedure that php is creating and executing against the server?
This is not the exact code but is is essentially what we are doing.
$stmt = mssql_init("sp_doSomething");
mssql_bind($stmt, "@sid", $sid, SQLINT4, false);
mssql_bind($stmt, "@value", $value, SQLINT4, false);
$result = mssql_execute($stmt);
I would love to be able to preview the actual SQL statement contained in $stmt.
Any help would be appreciated.
Upvotes: 0
Views: 448
Reputation: 34
if you windows user you can download 2 file 1.php_pdo_sqlsrv_56_ts.dll 2.php_sqlsrv_56_ts.dll and take php folder after change php.ini file add this line extension=php_pdo_sqlsrv_56_ts.dll and extension=php_pdo_sqlsrv_56_ts.dll and restart apache
$connection = mssql_connect('hostname', 'username', 'password');
if (!$connection) {
die('Unable to connect!');
}
if (!mssql_select_db('db-name', $connection)) {
die('Unable to select database!');
}
$vall='zanala';
$stmt = mssql_init("SYSTEM_USERS_FIND_BY_USERNAME",$connection);
mssql_bind($stmt, "@IN_USERNAME",$vall, SQLVARCHAR, false, false, -1);
$result=mssql_execute($stmt);
$row = mssql_fetch_assoc($result);
echo $my_id = $row['IID'];
Upvotes: 0
Reputation: 15616
SQL Query Profiler is a good tool to hook and watch what a SQL server doing right now in realtime. That would be useful.
Upvotes: 0