PHP - Connect to a database using a role and role password

From Ingres Community Wiki

Jump to: navigation, search
<?php

$database='dbname';
$user='user';
$password='password';


$options = array( "role" => "phprole_withpass/php");

$conn=ingres_connect($database,$user,$password, $options);

if ( !is_resource($conn) ) {
    echo "Error - " . ingres_errno() . " : " . ingres_error() . "\n";
    die("i died");
} 
else
{
    echo "Connection succeeded.";
}
$rc=ingres_query($conn,"select dbmsinfo('role') as role");

//echo ingres_num_rows($rc) . "\n";

if ( !is_resource($rc) ) {
    echo "Error - " . ingres_errno() . " : " . ingres_error() . "\n";
    die("i died");
} 
else
{
    $object = ingres_fetch_object ($rc);
    echo $object->role;
}

ingres_close($conn);
?>

Back to PHP Driver Examples

Personal tools
Developing With