<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="sr-RS">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<?php

/*
 * Demo: demo_getttable.php
 * 
 * Primer poziva API funkcije 'gettable' koja vraca tabelu. 
 *  
 */
 
include_once 'infoapi/infoapi.php';

$miapiHandler = new iapiHandler;
$miapiHandler->APIServerURL = SERVER_URL;

$miapiHandler->DebugLevel = DEBUG_LEVEL;
$miapiHandler->DebugSections = DEBUG_SECTIONS;


// naziv API funkcije koja se poziva
$mAPIFunctionName = 'GETTABLE';

$mQueryEnvelope = new iapiQueryEnvelope ($mAPIFunctionName);
$mQueryEnvelope->username = USERNAME;
$mQueryEnvelope->password = PASSWORD;

$mQueryEnvelope->data->table_name = 'tabela';
$mQueryEnvelope->data->result_database_format = 'NATIVE_OBJ';

$mQuery = $mQueryEnvelope;
$mResponse  = $miapiHandler->Execute($mQuery);

?>

<p>
<pre>
<?php //echo print_r ($mResponse->data->databaseattachment); ?>

<?php

$m_databaseattachment = $mResponse->data->databaseattachment;

//echo "<pre>";
//print_r ($m_databaseattachment->items);
//echo "</pre>";


foreach ($m_databaseattachment->items as $mTable) {

?>
<table border="1">
<caption><?php echo $mTable->table_name; ?></caption>
<tr>
<?php
   foreach ($mTable->fields->items as $mField) {
?>
<th><?php echo $mField->name; ?></th>
<?php
  }
?>
</tr>


<?php
   foreach ($mTable->rows->items as $mRow) {
     $mRow = (array)$mRow; // lakse je raditi sa slogom kao asocijativnim nizom nego kao sa objektom
?>
<tr>

<?php
     foreach ($mTable->fields->items as $mField) {
?>
<td><?php echo $mRow[strtolower ($mField->name)]; ?></td>
<?php
    }
?>

</tr>
<?php
  }
?>

</table>
<?php
 }
?>

Database format: <?php echo ($mResponse->data->database_format); ?>

</pre>
</p>

<?php

if ($mResponse->data->error_state !='ok') {
?>
Greska: <?php echo $mResponse->data->error_state; ?>
<?php
}
?>
<hr />

<?php include_once 'inc_sysinfo.php'; ?>

</body>
</html>