pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedsql command
7+ messages / 6 participants
[nested] [flat]
* sql command
@ 2002-05-02 15:32 PJourdan <info@lespetitsplaisirs.com>
2002-05-02 22:17 ` Re: sql command Scott Marlowe <scott.marlowe@ihs.com>
2002-05-02 23:08 ` Re: sql command Chris <csmith@squiz.net>
2002-05-03 14:00 ` Re: sql command P. Jourdan <pippo@videotron.ca>
2002-05-05 23:23 ` Re: sql command Chris <csmith@squiz.net>
0 siblings, 4 replies; 7+ messages in thread
From: PJourdan @ 2002-05-02 15:32 UTC (permalink / raw)
To: pgsql-php
Could someone explain to me why sql commands work in php with pgsql? I have
a curious situation where the author used sql commands like sqlconnect to
access the database rather than pg-connect as well as other commands that
are either psql or sql - I'm a litle confused here. This is in a .conf file:
sqlconnect(array('server'=>'tester.videotron.ca','user'=>'mum',
'database'=>'mum','password'=>'123456' ) );
I'm looking for the theory behind all this. :-)
Thanks
Phil Jourdan
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: sql command
2002-05-02 15:32 sql command PJourdan <info@lespetitsplaisirs.com>
@ 2002-05-02 22:17 ` Scott Marlowe <scott.marlowe@ihs.com>
3 siblings, 0 replies; 7+ messages in thread
From: Scott Marlowe @ 2002-05-02 22:17 UTC (permalink / raw)
To: P. Jourdan <pippo@videotron.ca>; +Cc: pgsql-php
Your machine almost certain is using some kind of universal connection
class / include file somewhere you don't know about.
try adding this to a simple script:
print implode("<BR>",get_included_files());
and see what it lists and look through the include files it shows (use
'locate include_file' where include_file is the name of the include file
shown in the php script...)
On Thu, 2 May 2002, P. Jourdan wrote:
> Could someone explain to me why sql commands work in php with pgsql? I have
> a curious situation where the author used sql commands like sqlconnect to
> access the database rather than pg-connect as well as other commands that
> are either psql or sql - I'm a litle confused here. This is in a .conf file:
> sqlconnect(array('server'=>'tester.videotron.ca','user'=>'mum',
> 'database'=>'mum','password'=>'123456' ) );
> I'm looking for the theory behind all this. :-)
> Thanks
> Phil Jourdan
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: sql command
2002-05-02 15:32 sql command PJourdan <info@lespetitsplaisirs.com>
@ 2002-05-02 23:08 ` Chris <csmith@squiz.net>
3 siblings, 0 replies; 7+ messages in thread
From: Chris @ 2002-05-02 23:08 UTC (permalink / raw)
To: P. Jourdan <pippo@videotron.ca>; pgsql-php
Hi Phil,
>Could someone explain to me why sql commands work in php with pgsql?
?? Why wouldn't they? :P
>I have a curious situation where the author used sql commands like
>sqlconnect to access the database rather than pg-connect as well as other
>commands that are either psql or sql - I'm a litle confused here. This is
>in a .conf file:
>sqlconnect(array('server'=>'tester.videotron.ca','user'=>'mum',
> 'database'=>'mum','password'=>'123456' ) );
>I'm looking for the theory behind all this. :-)
>Thanks
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).
Do a grep on your code tree for 'function sqlconnect' and look at the file
involved.
It's just a small wrapper function for the full command :)
-----------------
Chris Smith
http://www.squiz.net/
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: sql command
2002-05-02 15:32 sql command PJourdan <info@lespetitsplaisirs.com>
@ 2002-05-03 14:00 ` P. Jourdan <pippo@videotron.ca>
3 siblings, 0 replies; 7+ messages in thread
From: P. Jourdan @ 2002-05-03 14:00 UTC (permalink / raw)
To: Chris <csmith@squiz.net>; +Cc: 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
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: sql command
2002-05-02 15:32 sql command PJourdan <info@lespetitsplaisirs.com>
@ 2002-05-05 23:23 ` Chris <csmith@squiz.net>
3 siblings, 0 replies; 7+ messages in thread
From: Chris @ 2002-05-05 23:23 UTC (permalink / raw)
To: P. Jourdan <pippo@videotron.ca>; +Cc: pgsql-php
Hi Philip,
>>>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?
SQL is generic and specific. Sorry to be confusing :)
Each database system has a slightly different syntax for things but the
basics remain (to give really simple examples) :
INSERT INTO table_name (field1, field2, field3) VALUES (value1, value2,
value3) ..
UPDATE table_name SET field1=value1, field2=value2 WHERE field3=value3 ..
DELETE FROM table_name WHERE field1=value1 ..
SELECT field1, field2 FROM table_name WHERE field3=value3 ..
Differences come in with things like auto-increment fields, dates and times.
Example: MySQL uses an 'auto_increment' datatype, PostgreSQL uses a
'serial' datatype.
>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?
Sort of right. When you initially set it up, it can be a little bit of
extra work, but you can get a lot of advantage (time-saving) out of it.
You can now use it all over the place in your code, without worrying about
typos, you know it works and how it works etc. If you want to change it to
do something else (eg add logging), you only have to do it in one place,
instead of searching through all your code looking for places that need it.
The same reasons for any sort of function in any code exist here :)
-----------------
Chris Smith
http://www.squiz.net/
^ permalink raw reply [nested|flat] 7+ messages in thread
* sql command
@ 2005-03-29 05:12 Eko Budi Setiyo <eko@softhome.net>
2005-04-03 03:00 ` Re: sql command Christopher Kings-Lynne <chriskl@familyhealth.com.au>
0 siblings, 1 reply; 7+ messages in thread
From: Eko Budi Setiyo @ 2005-03-29 05:12 UTC (permalink / raw)
To: pgsql-php
Dear All,
Can any body help me about what SQL command to list "all data base" and
"all tables" on Postgres 8 by using PHP.
regards
Eko
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: sql command
2005-03-29 05:12 sql command Eko Budi Setiyo <eko@softhome.net>
@ 2005-04-03 03:00 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
0 siblings, 0 replies; 7+ messages in thread
From: Christopher Kings-Lynne @ 2005-04-03 03:00 UTC (permalink / raw)
To: Eko Budi Setiyo <eko@softhome.net>; +Cc: pgsql-php
SELECT * FROM pg_database;
Eko Budi Setiyo wrote:
> Dear All,
>
> Can any body help me about what SQL command to list "all data base" and
> "all tables" on Postgres 8 by using PHP.
>
> regards
> Eko
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2005-04-03 03:00 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-02 15:32 sql command PJourdan <info@lespetitsplaisirs.com>
2002-05-02 22:17 ` Scott Marlowe <scott.marlowe@ihs.com>
2002-05-02 23:08 ` Chris <csmith@squiz.net>
2002-05-03 14:00 ` P. Jourdan <pippo@videotron.ca>
2002-05-05 23:23 ` Chris <csmith@squiz.net>
2005-03-29 05:12 sql command Eko Budi Setiyo <eko@softhome.net>
2005-04-03 03:00 ` Christopher Kings-Lynne <chriskl@familyhealth.com.au>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox