opkg update
opkg install php5-cli php5-mod-pdo-pgsql
nano pgsql2.php
#!/usr/bin/php-cli
<?php
try
{
    $db = new PDO('pgsql:dbname=mypgdatabase;host=192.168.0.240','postgres','password');
    # Send errors as exceptions
    $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    # Run a query
    $sql = "select username, password from login;";
    $results = $db->query($sql);
    foreach($results as $row)
    {
        var_dump($row);
    }
} catch(\Exception $e)
{
    echo $e->getMessage();
}
?>
chmod 755 pgsql2.php
./pgsql2.php
array(4) {
  ["username"]=>
  string(7) "sonnyyu"
  [0]=>
  string(7) "sonnyyu"
  ["password"]=>
  string(8) "password"
  [1]=>
  string(8) "password"
}