Closed sunsided closed 9 years ago
Good catch - I've only used SQLite with this project so I never needed to specify a username or password. Are you planning on using a different database system?
I thought MariaDB/MySQL would be a good idea. Makes things a bit easier when it comes to manually deleting packages and such things, I guess. :)
I added support for this in 25a6b82fc026fb880ecb684d94db9bd9114d1b98. However, note that you may need to do schema changes to get it working in MySQL. Notably:
CREATE INDEX IF NOT EXISTS
to create an index only if it doesn't already existexec
in DB::createTables
would need to be split into multiple exec
sTEXT
columns to be indexed, so the PackageId
column in packages
may need to be changed to VARCHAR
. SQLite has no difference between VARCHAR
and TEXT
so this is not an issue in SQLite.Currently the code to create the database tables if they don't exist runs on every request, as that was the easiest way to do it (and allows easy iteration when debugging, you can just delete the SQLite file to get a fresh database on your next request). It might be worth only doing it when an installer script is ran. The installer script could run different DDL statements depending on the database system being used.
I'm currently working on a Docker image containing Nginx and HHVM in oder to quickly set up this server. It uses some shell scripts to replace the API key in the configuration file and I thought about doing the same with the PDO connection string.
However, from what I can tell, the PDO constructor requires the username and password to the database to be separate parameters, and these are not provided to the constructor in
db.php
, so there is currently no (sane) way for me make them configurable by the end user through environmental variables.Can you add support for those in the
inc/config.php
?