Jump to content

SeenGee

Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

SeenGee's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i need to perform a select on 5 tables in a postgre db, table a is linked to table b through an \'id\' explicity created in a and linked as foreign key in b. table b creates a primary key \'number\' which is declared as a foreign key in c, d and e. each number is related to an id from table a. i want to perform a select that pulls from the database every column from every table for each instance of \'number\'. in tables c d and e there may be multiple entries for each number. Thanks
  2. i need to join together 5 tables in a psql database i have made. the problem is that i cant seem to find the correct sql to perform the join. the tables i have are group, person, contacts, movements and treatments. group and person are connected by a group_id, established in group, each entry in the person table also has a group_id. the other tables are connected by person_number, established in person and a foreign key in all the other tables. Would really appreciate some help. Thanks.
  3. i\'m in the process of porting a script between mysql and postgres that writes to an xml file. thanks to some help on this forum i\'ve made most of the transitions i need in terms of functions i think but the script is still not working correctly. would appreciate any help people can give me to complete this transition. ORIGINAL SCRIPT FOR MYSQL --------------------------------------------------------------------------------- [php:1:30cb00a3ff] <?php $link = mysql_connect (\"localhost\", \"administrator\", \"password\"); mysql_select_db(\"IAD\", $link); $_xml = ( bool ) false; $result = mysql_query (\"describe users\", $link); $count = 0; while ($row = mysql_fetch_array($result)) { $fieldnames[$count] = $row[0]; $count++; } $file= fopen(\"user.xml\" , \"w\"); $_xml .=\"<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>rn\"; $_xml .=\"<!-- table users -->\"; $_xml .=\"<users>rn\"; $result = mysql_query (\"select * from users\", $link); while ($row = mysql_fetch_object($result)) { $count = 0; $_xml .=\" <record>rn\"; foreach ($row as $data) { $_xml .=\" <$fieldnames[$count]>$data</$fieldnames[$count]>rn\"; $count++; } $_xml .=\" </record>rn\"; } $_xml .=\"</users>\"; fwrite($file, $_xml); fclose($file); echo $_xml; mysql_close ($link); ?> [/php:1:30cb00a3ff] ------------------------------------------------------------------------------ MY AMENDED SCRIPT FOR POSTGRES [php:1:30cb00a3ff] <?php $conn = pg_connect(\"host= user= password=\'\' dbname=\"); if (!$conn) { echo \"<h1>Connection Error</h1>\"; exit; } $sql=\"SELECT * FROM user;\"; $result_set = pg_Exec ($conn, $sql); for ($j=0; $j<$rows; $j++) { list($user_id,$user_location) = pg_fetch_row($result_set, $j); } $file= fopen(\"user.xml\" , \"w\"); $_xml .=\"<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>rn\"; $_xml .=\"<!-- table users -->\"; $_xml .=\"<users>rn\"; $result_set = pg_Exec ($conn, $sql); for ($j=0; $j<$rows; $j++) { $row = pg_fetch_object($result, $row) } $_xml .=\" <record>rn\"; foreach ($row as $data) { $_xml .=\" <$fieldnames[$count]>$data</$fieldnames[$count]>rn\"; $count++; } $_xml .=\" </record>rn\"; } $_xml .=\"</users>\"; fwrite($file, $_xml); fclose($file); echo $_xml; pg_close(); ?> [/php:1:30cb00a3ff] Thanks for helping.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.