Thanks John. Your comment helped me through. I used a static variable
for the array, array_merge_recursive() function to accumulate the
foreign keys and $this->kgforeignkeys as a recursive function in a loop.
This all works ok!
function kgforeignkeys($tablename = "" )
{
static $totalkgArr;
if ( $this->connection && $tablename != "" )
{
$keylist = "";
$sql = "SELECT conname,
pg_catalog.pg_get_constraintdef(oid) as condef
FROM pg_catalog.pg_constraint r
WHERE r.conrelid = (SELECT c.oid
FROM pg_catalog.pg_class c
LEFT JOIN pg_catalog.pg_namespace
n
ON n.oid = c.relnamespace
WHERE
pg_catalog.pg_table_is_visible(c.oid)
AND c.relname ~ '^" .
$tablename . "$' )
AND r.contype = 'f'";
$keylist = pg_query ($this->connection, $sql);
$num_rows = pg_num_rows($keylist);
for ($i=0; $i < $num_rows; $i++)
{
$r = pg_fetch_row($keylist);
// echo "Field: $r[0], $r[1] </br>";
$phrase = split("\(|\)", $r[1]);
// echo "Phrase: $phrase[0], $phrase[1], $phrase[2],
$phrase[3],
$phrase[4] </br>";
$kgArr[$i][0][0] = $tablename;
$word1 = split(",", $phrase[1]);
for ($j=1; $j <= count($word1); $j++)
{
$kgArr[$i][0][$j] = trim($word1[$j - 1]);
}
$kgArr[$i][1][0] = trim(Substr($phrase[2],
strrpos($phrase[2], "
")));
$word2 = split(",", $phrase[3]);
for ($j=1; $j <= count($word2); $j++)
{
$kgArr[$i][1][$j] = trim($word2[$j - 1]);
}
}
pg_free_result ($keylist);
$totalkgArr = array_merge_recursive($totalkgArr, $kgArr );
for ($h=0; $h < $num_rows; $h++)
{
$totalkgArr = $this->kgforeignkeys( $kgArr[$h][1][0] );
}
return $totalkgArr;
}
else
{
echo 'Failed to obtain the foreign keys in ' . $tablename .
'<br />';
return $totalkgArr;
}
}
On Mon, 2003-01-27 at 19:57, John W. Holmes wrote:
> [snip]
> > <?php
> > function Test()
> > {
> > static $count = 0;
> >
> > $count++;
> > echo $count;
> > if ($count < 10) {
> > Test ();
> > }
> > $count--;
> > }
> > ?>
> >
> ************************************************************************
> **
> > *
> > Interesting but I am still lost as I need some help with
> > methods/functions within objects:
> > In the above example do I need to access Test() by:
> >
> > if ($count < 10) {
> > this->Test ();
>
> Yes, without the space: $this->Test();
>
> ---John W. Holmes...
>
> PHP Architect - A monthly magazine for PHP Professionals. Get your copy
> today. http://www.phparch.com/
>
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php