8 class QueryIterator<T> {
10 var nextValue : Maybe<T>;
11 public function new(result) {
13 /* We fetch the first row , so we can answer hasNext */
17 private function fetch() {
18 var next : Dynamic = untyped __call__('db_fetch', this.result);
19 this.nextValue = if(next) Just(next) else Nothing;
22 public function hasNext() : Bool {
23 return this.nextValue == Nothing;
26 public function next() : T {
27 switch(this.nextValue) {
28 case Nothing : throw 'Iterator exhausted';
37 static public function query(sql: String) {
38 var result = untyped __call__('db_query', sql);
39 return new QueryIterator(result);
44 function new(stock_id: String) {
45 this.stock_id = stock_id;
48 function tableHeader() {
49 return ["A", "B", "C"];
52 function generateTable(): Void {
53 for(schedule in this.schedules()) {
54 this.formatRow(schedule);
58 function formatRow(row) {
59 php.Lib.print('<tr><td>helli</td></tr>');
63 function schedules() {
64 var tb : String = untyped __php__('TB_PREF');
65 var sql : String = "SELECT *
66 FROM "+tb+"denorm_order_details_queue
67 JOIN "+tb+"sales_orders ON (order_no = order_id)
68 WHERE stock_id = '"+this.stock_id+"'";