Dan was using a third-party database which provided a PHP API. At one point, Dan was running into an issue where he actually needed locks on the database. Fortunately for him, the vendor documentation told him that there was a method called obtainRowLock
.
obtainRowLock($table, $where) - Attempt to lock a row, will escalate and lock the table if row locking is not supported, will escalate and lock the database if table locking is not supported; returns true on success, false on failure
$table - name of table to lock
$where - WHERE clause to define rows, ex: "WHERE id=52". If left empty, function will assume a table lock
That was exactly what Dan needed, so he called it. It returned false, implying a failure. He changed the parameters. He discarded his where clause. He tried all sorts of things, and it always returned false. So he dug into the source code, to see how it actually worked.
function obtainRowLock($table, $where)
{
return false;
}
Is it truly a failure if you don't even try?
