Home: PHP Diary | Script School | PHP Scripts | TD Scripts.com
Link Organizer - A comprehensive link list organizer


[back]
go back 01/15/03 "How to install and configure PostgreSQL and use with PHP" go forward[next]

PostgreSQL Tips

Getting installed and connected to the postgresql database at the shell level is a little different than mySQL. Here is some helpful info for reference.

Short Installation: http://www.postgresql.org/idocs/index.php?installation.html

./configure
gmake
su
gmake install
adduser postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test

You will need to login as user "postgres" per the standard docs install. To do this you would type:

su - postgres

Now that you are user "postgres" you can create your first Postgresql database. It's easier than you might think:

createdb mydb

Remember that you may need to use the full path so something like:

/usr/local/postgres/createdb mydb

If successful, then you should receive the message:
CREATE DATABASE

Now you can get to the the PostgreSQL interactive terminal by typing the following into the shell:

DIRECT method:
psql mydb

FULL PATH method:
/usr/local/pgsql/bin/psql mydb

If this is successful you will see the following message:

Welcome to psql, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

Now you can enter in commands from all those PostgreSQL books and articles you find and create tables and query the table data directly from PHP using the PostgreSQL functions: http://www.php.net/manual/en/ref.pgsql.php 

Here is the PHP manual information for doing a pg_query (PostgreSQL query) using php:
http://www.php.net/manual/en/function.pg-query.php

For more information, please consult the Script School newsletter #47: http://www.scriptschool.com/news/issue47.phtml 

Happy coding to you!

Please vote on the usefulness of this diary entry so other people will know if it is worth their time to read :)

How useful was this diary entry? Avg Surfer Rating: 3.60 (125)

New forum for discussion of diary entries

The homeroom at Script School is available to discuss this and other php-scripts.com diary entries. You must be an enrolled student at Script School to add comments to these diary entries.

[back]go back 01/15/03 "How to install and configure PostgreSQL and use with PHP" go forward[next]

Home: PHP Diary | Script School | PHP Scripts | TD Scripts.com

Copyright 1999-2003 php-scripts.com Last Modified 01/21/03 05:11