3.2.0

Connect to Oracle 10g and Retrieving data into Grid

Hello to every one, am trying display data from oracle 10g into the Grid of active widgets but my code is failing to dislplay and error is indicated on $rows = oci_fetch_row($dataset, OCI_DEFAULT);
Could some body help me.
sample code is below that I have trying to query my database using oci functions in oracle with php:
<?php

$conn = ocilogon('scott', 'tiger', '//localhost/TIN');

$query = 'select * from emp';

$dataset= oci_parse($conn, $query);
oci_execute($dataset, OCI_DEFAULT);

// print Oracle query results as 2D javascript array
function aw_cells($dataset){
$rows = oci_fetch_row($dataset, OCI_DEFAULT);
while ($record = oci_fetch_array($dataset, OCI_ASSOC)) {
$cols = array();
foreach ($record as $value) {
$cols[] = '"'.addslashes($value).'"';
}
$rows[] = "\t[".implode(",", $cols)."]";
}
echo "[\n".implode(",\n",$rows)."\n];\n";
}


// print Oracle field names as javascript array
function aw_headers($dataset){
while ($field = oci_field_name($dataset)) {
$cols[] = '"'.$field->name.'"';
}
echo "[".implode(",",$cols)."];\n";
}

//oci_free_statement($dataset);
//ocilogoff($conn);
?>
<html>
<head>
<!-- include AW stylesheet and script -->
<link href="../../runtime/styles/xp/aw.css" rel="stylesheet" type="text/css" ></link>
<script src="../../runtime/lib/aw.js"></script>
</head>
<body>
<script>

// insert javascript arrays produced by PHP functions
var myHeaders = <?= aw_headers($dataset) ?>
var myCells = <?= aw_cells($dataset) ?>

// create grid control
var obj = new AW.UI.Grid;

// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

// write grid to the page
document.write(obj);

</script>
</body>
</html>
Johannes Karaze
April 29,

This topic is archived.

See also:


Back to support forum