Remove useless MySQL propriatary backtics

Nearly all backtics used are not required. The only one that will clash is 'convert' as that is a reserved
MySQL reserveword [0].

This patch cleans up all backtics as those are not cross-db and propriatery to MySQL. The Ansi-SQL version
of double quotes needs special support from MySQL which isn't enabled by default, so we can't use that.

By using this patch, it will become easier to use other databases next to MySQL for datastorage.

[0] http://dev.mysql.com/doc/mysqld-version-reference/en/mysqld-version-reference-reservedwords-5-0.html

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
processList is the only camelCased table entry, lowercase it

processList seems to be the only column in a table that is camelCased,
this looks out of place and inconsistent. This patch renames all
instances and references.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
Use the DataType enum for datatypes

We have a DataType enum so we don't use hardcoded values, lets make use
of it.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
Abstract MySQL out from the core code and add a simple abstraction layer

The current PHP code uses mysql directly everywhere. Even when using timestore as the main database mysql
still is a hard dependancy. To ease the transistion to possibly using Postgres and/or SQLite in combination
with timestore, it is neccesary to abstract out mysql into an abstraction layer and make calls generic.

This patch does just that and because of that adds Lib/db.php, the database abstraction layer. Queries which
are standard SQL are just passed to this library.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
db_check is a little out of its place in core.php, move it to Lib/db.php

With this patch we move db_check to the other db_ functions. This feels
more appropiate place.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
Add PostgreSQL support

With the previous cleanup, it is now quite easy to expand further
database support. This patch adds support for the PostgreSQL database.

There is a new concept of dealing with time as an actual timestamp or
the timeseries log. A new unused function is added that needs some
tuning and testing, got_data(), which uses the idea of using the
database's resolution for time rather then calculating our own using
date_trunc.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
Add (PDO)SQLite support

This patch adds SQLite support to emoncms. There is one big caveat
however that wasn't solved yet. When using SQLite as a timeseries store,
it is currently not possible to drop tables. When issuing the delete
command from the Webinterface, the table appears to be removed, but the
actual table in the database remains. Since most users will use
timestore for the timeseries log, this most likly won't be a huge issue.

SQLite is also optimized for speed but none of the optimizations have been
preformed such as optimizing the number of writes by caching it in memory
first. Carefully tuning SQLite makes it actually possible to have it
perform as if it where run from memory.

One optimization is to use BEGIN TRANSACTION and END TRANSACTION around
queries and while that is technically possible in db_query, this should
be left to a second patch once SQLite is more stable.

The second optimization is to use PRAGMA to tune parameters. Two
important ones are:
	synchronous=OFF
	temp_store=MEMORY

As with postgres, the current database update mechanism isn't done nor
tested, only creating new databases is.

Signed-off-by: Oliver Schinagl <oliver@schinagl.nl>
Merge pull request #107 from oliv3r/wip/seperate_db

Abstract MySQL and add postgresqlite support