Some time ago we talked about the PostgreSQL database, and showed you some command line (installation and) usage via a MacBook Pro Terminal application’s (bash environment) command line.
So that showed a bit of SQL for PostgreSQL and you can see it is a lot like other database SQL, and am not about to tell you otherwise today.
The only SQL part that may not be transportable to other database SQL today, is the use of the PostgreSQL “to_date()” function, but the lesson is that so much relational database coalesces with the SQL (DML) for …
- SELECT (query the database) … for reading …
- INSERT (add record to the database) … for writing …
- UPDATE (amend a record of the database) … for writing …
- DELETE (delete record of the database) … for writing (oddly)
… they all have six letters, and know that has made things cute programmatically for me in the past.
So it is good to not let database work phase you for the way you live with it from day to day with the commands above … but what is sometimes more confusing is the way you connect with databases … generally it involves …
- hostname (and port, perhaps)
- username
- password
- database (mostly)
- access rules (occasionally)
We’ve talked about PHP and MySql a fair bit at this blog, and the fact is PHP can quite effectively work with PostgreSQL as well, which we show you today with our local (Mac) MAMP local web server, but do not have available at the domain rjmprogramming.com.au, which PHP was not compiled to include module “pgsql” … the PHP command “phpinfo()” will tell you what the state of play is with your Apache/PHP web server with regard to this.
So today, on MAMP, we take up where we left off with PostgreSQL Primer Tutorial as shown below, and write some PHP you could call pg.php to perform SQL (DML) on that “films” table of that tutorial below.
You can INSERT and UPDATE and DELETE to the database, and behind the scenes we SELECT all the database records of the “films” table to keep you up to date with how things sit.
We used the great Gifpal to create an animated GIF (of a MAMP session execution) for your perusal here.
Link to PostgreSQL Database Server more information … via Wikipedia.
Link to PostgreSQL Database Server home … Open Source.
Link to PostgreSQL Database Server … documentation.
Hope you get something out of today’s database (and PHP) offering.
Previous relevant PostgreSQL Primer Tutorial is shown below.
Welcome to the PostgreSQL (Database Server) Primer Tutorial.
The PostgreSQL Database Server product is an excellent Open Source database that has been established for many years. PostgreSQL is an object-relational database management system, and read along with Wikipedia, how its emphases are extensibility and standards-compliance.
Doing this tutorial, and please forgive my naivety with PostgreSQL, I was amazed at the DDL similarities with those databases I was more familiar with, namely MySql, MS-SQL, Oracle, Advantage and Access, and can imagine setting up workable systems in a short space of time.
In the primer tutorial you can see early parts of an install to a MacBook Pro and its “psql” command line interface, like the wonderful “sqlplus” interface of Oracle.
Link to PostgreSQL Database Server more information … via Wikipedia.
Link to PostgreSQL Database Server home … Open Source.
Link to PostgreSQL Database Server … documentation.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
21 Responses to PostgreSQL PHP Tutorial