PHP - Specifying the default structure for a newly created table

From Ingres Community Wiki

Jump to: navigation, search

Specifying the default structure for a newly created table.

<?php

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

$options = array( "table_structure" => INGRES_STRUCTURE_BTREE );

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

if ( ingres_errno($conn) ) {
    $error_code=ingres_errno();
    $error_text=ingres_error();
    $error_sqlstate=ingres_errsqlstate();
    printf ( "Error during connect : %s\n\r",$error_code);
    printf ( "Error during connect : %s\n\r", $error_text);
    printf ( "Error during connect : %s\n\r", $error_sqlstate);
    die("i died");
} 
else
{
    echo "Connection succeeded.";
}
$rc=ingres_query($conn,"create table table_structure as select * from iirelation");

if ( ingres_errno() ) {
    $error_code=ingres_errno($conn);
    $error_text=ingres_error($conn);
    $error_sqlstate=ingres_errsqlstate($conn);
    printf ( "Error during query : %s\n\r",$error_code);
    printf ( "Error during query : %s\n\r", $error_text);
    printf ( "Error during query : %s\n\r", $error_sqlstate);
    die("i died");
} 

$rc=ingres_query($conn,"select * from iitables where table_name = 'table_structure'");

if ( ingres_errno() ) {
    $error_code=ingres_errno($conn);
    $error_text=ingres_error($conn);
    $error_sqlstate=ingres_errsqlstate($conn);
    printf ( "Error during query : %s\n\r",$error_code);
    printf ( "Error during query : %s\n\r", $error_text);
    printf ( "Error during query : %s\n\r", $error_sqlstate);
    die("i died");
} 
else
{
    while ( $object = ingres_fetch_object ($rc) ) {
        echo "The table, table_structure has the storage structure, " . trim($object->storage_structure) . ".";
    }
}

ingres_close($conn);
?>

Back to PHP Driver Examples

Personal tools
Developing With