Make lastInsertedId return null on failure.

Since we're rejiggering, we'll take this opportunity to eliminate the use of -1
as a sentinel id. Maybe your database id generator returns -1. Unlikely, but
not impossible.