Re: sql command

From: "P(dot) Jourdan" <pippo(at)videotron(dot)ca>
To: Chris <csmith(at)squiz(dot)net>
Cc: pgsql-php(at)postgresql(dot)org
Subject: Re: sql command
Date: 2002-05-03 14:00:25
Message-ID: 5.1.0.14.2.20020503092500.00ad3e98@pop.videotron.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

At 09:08 AM 5/3/2002 +1000, Chris Smith wrote:

>>Could someone explain to me why sql commands work in php with pgsql?
>
>?? Why wouldn't they? :P

I'm too new at this to understand. That's why I ask. What I don't
understand is this: is sql generic as opposed to specific comands in mySQL
and/or postgreSQL?
I now understand that in my problem below you are right, there was an
sqlconnect function created as you suggested below.
Then, what would be the reason to use this sqlconnect function rather than
pg_connect? Can't parameters be passed on to the pg_connect in the same way
as they are passed on to the created sqlconnect? It seems like extra work
or a bit of redundancy in creating a function that exists?

>It looks like the author wrote a function called 'sqlconnect' which takes
>an array of data to (obviously) connect to the server.
>
>The function would probably look something like this:
>
>function sqlconnect($connectionarray) {
>pg_connect("host=$connectionarray['server'] user=$connectionarray['user']
>password=$connectionarray['password'] dbname=$connectionarray['database']");
>}
>
>(with more error checking and comments of course).

This is what I found (the MySQL references are there because the db was
migrated from MySQL to PostgreSQL):

function SQLConnect($params='') {
global $dbh;
/*
* MySQL equivalent:
* $dbh=mysql_pconnect( $db_server,$db_user,$db_password );
*/
if(isset($params['server'])) {
$connect="host=".$params['server'];
}
else {
$connect='host=localhost';
}
if(isset($params['port'])) {
$connect.=' port='.$params['port'];
}
else {
$connect.=' port=5432';
}
if(isset($params['user'])) {
$connect.=' user='.$params['user'];
}
if(isset($params['database'])) {
$connect.=' dbname='.$params['database'];
}
if(isset($params['password'])) {
$connect.=' password='.$params['password'];
}
$dbh=pg_pconnect($connect);
}

Thanks,
Philip

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Keary Suska 2002-05-03 17:53:50 Re: Getting Image coordinates when mouse is clicked on the
Previous Message arun kv 2002-05-03 13:26:29 Getting Image coordinates when mouse is clicked on the image and storing it in a variable