import php.Lib;
+
+enum Maybe<T> {
+ Nothing;
+ Just(v : T);
+}
+
+class QueryIterator<T> {
+ var result : Dynamic;
+ var nextValue : Maybe<T>;
+ public function new(result) {
+ this.result= result;
+ /* We fetch the first row , so we can answer hasNext */
+ fetch();
+ }
+
+ private function fetch() {
+ var next = untyped __call__('db_fetch', this.result);
+ this.nextValue = if(next) Just(next) else Nothing;
+ }
+
+ public function hasNext() : Bool {
+ return this.next == Nothing;
+ }
+
+ public function next() : T {
+ switch(this.nextValue) {
+ case Nothing : throw 'Iterator exhausted';
+ case Just(v) : return v;
+ }
+ }
+}
+class FA {
+ static public function query(sql: String) {
+ var result = untyped __call__('db_query', sql);
+ return QueryIterator(result);
+ }
+}
class ItemScheduler {
var stock_id:String;
function new(stock_id: String) {
}
function schedules() {
- return ["a", "b", "c"];
+ var tb : String = untyped __php__('TB_PREF');
+ var sql : String = "SELECT *
+ FROM "+tb+"denorm_order_details_queue
+ JOIN "+tb+"sales_orders ON (order_no = order_id)
+ WHERE stock_id = '"+this.stock_id+"'";
+ return FA.query(sql);
}
}