Throw a RuntimeException if the db function fails in script.php

As noted by @wilsonge here: https://github.com/joomla/joomla-cms/pull/4902#issuecomment-60255535

So i hopefully correct convert the old `if ($db->getErrorNum())` to Throw a `RuntimeException`.

Can you have a look into it @wilsonge?