The Daily WTF
Mark was debugging some database querying code, and got a bit confused about what it was actually doing. Specifically, it generated a query block like this:
$statement=”declare @status int declare @msg varchar(30) exec @status=sp_doSomething ‘arg1’, … select @msg=convert(varchar(10),@status) print @msg “; $result = sybase_query ($statement, $this->connection);
Run a stored procedure, capture its return value in a variable, stringify that variable and print it. The select/print must be for debugging, right? Leftover debugging code. Why else would you do something like that?
if (sybase_get_last_message()!==’0′) { … }
Oh no. sybase_get_last_message gets the last string printed out by a print statement. This is a pretty bonkers way to get the results of a function or procedure call back, especially when if there are any results (like a return value), they’ll be in the $result return value.
Now that said, reading through those functions, it’s a little unclear if you can
To read the full article click on the 'post' link at the top.