Delicious Bookmark this on Delicious Share on Facebook SlashdotSlashdot It! Digg! Digg



PHP : Function Reference : SESAM Database Functions : sesam_query

sesam_query

Perform a SESAM SQL query and prepare the result ()
string sesam_query ( string query [, bool scrollable] )

Example 2216.  Show all rows of the "phone" table as a HTML table

<?php
if (!sesam_connect("phonedb", "demo", "otto"))
   die(
"cannot connect");
$result = sesam_query("select * from phone");
if (!
$result) {
   
$err = sesam_diagnostic();
   die (
$err["errmsg"]);
}
echo
"<table border>\n";
// Add title header with column names above the result:
if ($cols = sesam_field_array($result)) {
   echo
"<tr><th colspan=" . $cols["count"] . ">Result:</th></tr>\n";
   echo
"<tr>\n";
   for (
$col = 0; $col < $cols["count"]; ++$col) {
       
$colattr = $cols[$col];
       
/* Span the table head over SESAM's "Multiple Fields": */
       
if ($colattr["count"] > 1) {
           echo
"<th colspan=\"" . $colattr["count"] . "\">" . $colattr["name"] .
               
"(1.." . $colattr["count"] . ")</th>\n";
           
$col += $colattr["count"] - 1;
       } else
           echo
"<th>" . $colattr["name"] . "</th>\n";
   }
   echo
"</tr>\n";
}

do {
   
// Fetch the result in chunks of 100 rows max.
   
$ok = sesam_fetch_result($result, 100);
   for (
$row=0; $row < $ok["rows"]; ++$row) {
       echo
" <tr>\n";
       for (
$col = 0; $col < $ok["cols"]; ++$col) {
           if (isset(
$ok[$col][$row])) {
               echo
"<td>" . $ok[$col][$row] . "</td>\n";
           } else {
               echo
"<td>-empty-</td>\n";
           }
       }
       echo
"</tr>\n";
   }
} while (
$ok["truncated"]); // while there may be more data

echo "</table>\n";
// free result id
sesam_free_result($result);
?>

Change Language


Follow Navioo On Twitter
sesam_affected_rows
sesam_commit
sesam_connect
sesam_diagnostic
sesam_disconnect
sesam_errormsg
sesam_execimm
sesam_fetch_array
sesam_fetch_result
sesam_fetch_row
sesam_field_array
sesam_field_name
sesam_free_result
sesam_num_fields
sesam_query
sesam_rollback
sesam_seek_row
sesam_settransaction
eXTReMe Tracker