I wanted to write a simple forum site with PHP that can be configured to use MySQL or PostgreSQL. Currently there are PDO, but I don't know OOP and I don't want to learn it. I have an idea about a function that take an argument about server software, and use either the mysqli or pgsql extension. For example:
function db_connect($mysql = null, $hostname, $username, $password, $database, $software)
{
switch ($software)
{
case "mysql":
return mysqli_real_connect($mysql, $hostname, $username, $password, $database);
case "pgsql":
return pgsql_connect("host=$hostname, port=5432, dbname=$database, user=$username, password=$password");
}
}
is that a good idea? Currently I don't need much functions to work yet.