I'm new to XML!

is it possible to have a direct connection to database?
how do I do it?

$conn = pg_connect("user=xxx dbname=xxx password=xxx");

if( $conn != 0)

if(!$err)
{
$sql = 'select id,name';
$sql .= ' from t_people';
$sql .= ' order by name';
$result = pg_exec($conn,$sql);
if(!$result)
$err = 11;
what do I need?