<?php require_once 'DB.php'; //------------------------------------------------------------------------------------------ // Get mother data from PostgreSQL as an associative array for cascade select. // motherTable: The table with the mother data. // motherPk: The primary key of the table with the mother data. // motherValue: The mother data value. //------------------------------------------------------------------------------------------ function getMotherData($dbserver,$dbuser,$dbpass,$dbname,$motherTable, $motherPk, $motherValue){ $driver='pgsql'; $dsn=$driver.'://'.$dbuser.':'.$dbpass.'@'.$dbserver.'/'.$dbname; $dbh=DB::connect($dsn); if(DB::isError($dbh)) { die("Connection Error: ".$dbh->getMessage()); } $query = "SELECT $motherPk, $motherValue FROM $motherTable;"; $data = $dbh->getAssoc($query); return $data; }
//------------------------------------------------------------------------------------------ // Get child data from PostgreSQL as an associative array for cascade select. // childTable: The table with the child data. // childFk: The foreing key of the table with the child data. // childPk: The primary key of the table with the child data. // childValue: The child data value. //------------------------------------------------------------------------------------------ function getChildData($dbserver,$dbuser,$dbpass,$dbname,$childTable,$childFk,$childPk,$childValue) { $driver='pgsql'; $dsn=$driver.'://'.$dbuser.':'.$dbpass.'@'.$dbserver.'/'.$dbname; $dbh=DB::connect($dsn); if(DB::isError($dbh)) { die("Connection Error: ".$dbh->getMessage()); } $query = "select $childFk, $childPk, $childValue from $childTable;"; $result= $dbh->query($query); $dbh->setFetchMode(DB_FETCHMODE_ORDERED); $data = array(); while ($row = $result->fetchRow()) { $data[$row[0]][$row[1]] = $row[2]; } return $data; } ?>
|