Database access is one of the initial objectives of the creation of BEE. It caters not only for basic data access operations such as select, update, insert and delete, but also useful features such as user-defined field encoding and decoding, multiple-field search criteria including range test and regular expression matching, display paging in long search result, and many more.
How about we starts with a simple query:
database phbook query="select * from PhoneBook";
foreach ((db)phbook) display "{foreach|list}<br>";
The output is a too long to be completely included here but you can check it from the online interpretor. Here is a sample listing:
ID=>'16',Name=>'Joe Chan',Tel=>'98765432',Height=>'178',Birthday=>'985260627' ID=>'17',Name=>'Dick Smith',Tel=>'87654321',Height=>'147',Birthday=>'0' ...
It does not look very good. So we put in some table formatting. (As we do BEE Script and HTML in and out, we include the <script ...> and </script> tags here.)
<table>
<tr>
<td><b>ID</b></td>
<td><b>Name</b></td>
<td><b>Tel</b></td>
<td><b>Height</b></td>
<td><b>Birthday</b></td>
</tr>
<script language="bee">
database phbook query="select * from PhoneBook";
foreach ((db)phbook as rec) {
</script>
<tr>
<td>${rec:ID}</td>
<td>${rec:Name}</td>
<td>${rec:Tel}</td>
<td>${rec:Height}</td>
<td>${rec:Birthday}</td>
</tr>
<script language="bee">
}
</script>
</table>
Now we have:
ID Name Tel Height Birthday
16 Joe Chan 98765432 178 985260627
17 Dick Smith 87654321 147 0
|