MSSQL Stored Procedure
Posted: Tue Jul 13, 2010 5:49 pm
Having some difficulty with stored procedures. I'm getting a boolean TRUE result back when executing the procedure, indicating it didn't fail, but I'm unable to retrieve any results. If I just perform a query on the procedure, i.e. "exec usp_ProcedureName @param1='value1', @param2='value2'", it does return the expected data.
Here's a snippet from my current code:
I get a warning saying: mssql_fetch_assoc() expects parameter 1 to be resource, boolean given. Can anyone tell me what I'm doing wrong? Or is this something with the stored procedure? I thought it was unlikely that the stored procedure would be the issue since just executing the procedure with mssql_query does work.
Thanks very much for any help, I appreciate it.
Here's a snippet from my current code:
Code: Select all
$sth = mssql_init($query, $this->dbh);
if(is_array($params))
{
foreach($params as $name => $value)
{
$success = mssql_bind($sth, $name, $value, SQLVARCHAR, false, false);
if(!$success)
{
throw new \Errors\SqlException('Failed to bind paramater.', 0, print_r(array($query, $params, mssql_get_last_message()), true));
}
}
}
$result = mssql_execute($sth) or die('Failed to execute.');
while($row = mssql_fetch_assoc($result))
{
// Do stuff
}
Thanks very much for any help, I appreciate it.