April 2026
Intermediate
1009 pages
34h 15m
English
The database may have a different name and work differently from the previous ones, but the relevant tasks are always the same: establishing a connection, sending SQL commands, and querying return values. Conveniently, even the functions have similar names.
The function for connection to a PostgreSQL database is called pg_connect() (or pg_pconnect(), where the p stands for persistent). All PHP PostgreSQL functions start with the prefix pg_. You specify a connection string as a parameter. There are many possibilities for this; here you can see a version with a lot of information (and an insecure password):
"host=localhost port=5432 dbname=PHP user=postgres password=pwd."
You ...
Read now
Unlock full access