|
|
| version 1.99, 2001/08/03 11:54:19 | version 1.100, 2001/08/07 13:54:13 |
|---|---|
| Line 616 static void _sql(Request& r, const Strin | Line 616 static void _sql(Request& r, const Strin |
| Value& statement=params->as_junction(0, "statement must be code"); | Value& statement=params->as_junction(0, "statement must be code"); |
| ulong limit=0; | ulong limit=0; |
| if(params->size()>1) { | |
| Value& limit_code=params->as_junction(1, "limit must be expression"); | |
| limit=(uint)r.process(limit_code).as_double(); | |
| } | |
| ulong offset=0; | ulong offset=0; |
| if(params->size()>2) { | if(params->size()>1) { |
| Value& offset_code=params->as_junction(2, "offset must be expression"); | Value& options_param=params->as_no_junction(1, "options must be hash, not code"); |
| offset=(ulong)r.process(offset_code).as_double(); | if(Hash *options=options_param.get_hash()) { |
| if(Value *vlimit=(Value *)options->get(*sql_limit_name)) | |
| limit=(ulong)r.process(*vlimit).as_double(); | |
| if(Value *voffset=(Value *)options->get(*sql_offset_name)) | |
| offset=(ulong)r.process(*voffset).as_double(); | |
| } else | |
| PTHROW(0, 0, | |
| &method_name, | |
| "options must be hash"); | |
| } | } |
| Temp_lang temp_lang(r, String::UL_SQL); | Temp_lang temp_lang(r, String::UL_SQL); |
| Line 812 MTable::MTable(Pool& apool) : Methoded(a | Line 815 MTable::MTable(Pool& apool) : Methoded(a |
| add_native_method("join", Method::CT_DYNAMIC, _join, 1, 1); | add_native_method("join", Method::CT_DYNAMIC, _join, 1, 1); |
| // ^table:sql[query][(count[;offset])] | // ^table:sql[query] |
| add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 3); | // ^table:sql[query][$.limit(1) $.offset(2)] |
| add_native_method("sql", Method::CT_DYNAMIC, _sql, 1, 2); | |
| // ^table:dir[path] | // ^table:dir[path] |
| // ^table:dir[path][regexp] | // ^table:dir[path][regexp] |