I hope this question isn’t too simple, I tried to go through the postgresql and mysql php pages, but I didn’t understand quite that well.
If you use PHP with MySQL, you can do something like this:
$_connectionID = @mysql_connect(
$dbConnectionConfig['host'],
$dbConnectionConfig['user'],
$dbConnectionConfig['pass'],
true
);
@mysql_select_db($dbName, $_connectionID);
Uhmm, two quick questions:
-
What’s the point of doing the above? Why not just do everything at once with
mysql_pconnect? -
What does the
trueinmysql_connectdo? Does it just allow you to have multiple database connections open at the same time?
Now, how would you go and do this in PostgreSQL? I know about pg_connect, but that requires a db name to be specified, so, it’s more of an equivalent to mysql_pconnect. Also, I know that the @ in the mysql php syntax basically hides the errors in case of failure. Does the @ work for postgres as well?
Thanks for your time, have a good day.
truetrueis only needed if it is a new connection link and you have already made a link before.@symbols because they block any PHP warnings that may come up