Working with latest postgresl (pgsql) and php releases (Mandriva cooker 2009.1)
I am assembling data to populate a composite table for active searching.
In simple terms, let us assume i have a table A and a table B. Each table has the same primary key code which we can call pkA and pkB.
Table A has a row for each code we will be dealing with, while Table B has all possible rows.
Only the code, as represented in pkA and pkB, is common.
There are many more tables to be dealt with, but they all fall into this scenario.
So .... I need in this case to first establish a query to run through Table A:
$query = "SELECT pkA FROM tableA";
$result = pg_query($query);
Then we would run through the data and assign the working variable
while($row = pg_fetch_array($result,NULL,PGSQL_ASSOC))
{
$code = $row[''pkA'];
Now I get confused as to how to proceed. Within the while loop I need to locate the matching record in tableB with something like $query2 = "SELECT pkB, otitle FROM tableB WHERE
pkb = '$code'";
Should I not be able to use $query3 = "UPDATE tableA SET otitle = '$otitle' WHERE pkA = $code'"; (within the while loop) ??
Is there a better way?
Any guidance would be much appreciated..