For an excellent all-round reference to database theory and SQL, the #1 book for you is Database Systems by Connolly et al - there is very little in there that directly relates to a specific DBMS, and that makes it easy to use no matter which database you have chosen. This is the book I turn to when I have an SQL query.
If you are looking for specific information on MySQL or PostgreSQL, there are two excellent books in the same programming series that you should definitely look at: "MySQL", by Paul DuBois, and "PostgreSQL", by Douglas and Douglas. These are both exceptionally comprehensive books and should really be on the bookshelves of all MySQL/PostgreSQL database admins.
Both PEAR::DB and SQLite have their own sets of documentation online. PEAR::DB's documentation is online at http://pear.php.net/manual/en/package.database.php, and is remarkably thorough if a little out of date now and then. The online documentation for the original SQLite's library is online at http://www.hwaci.com/sw/sqlite, and I have found that it complements the PHP manual well.
Copyright ©2015 Paul Hudson. Follow me: @twostraws.