|
|
| version 1.233, 2007/08/28 09:28:18 | version 1.234, 2007/08/28 10:34:49 |
|---|---|
| Line 41 DECLARE_CLASS_VAR(table, new MTable, 0); | Line 41 DECLARE_CLASS_VAR(table, new MTable, 0); |
| extern String cycle_data_name; | extern String cycle_data_name; |
| // defines for globals | |
| #define SQL_BIND_NAME "bind" | |
| #define SQL_DEFAULT_NAME "default" | |
| #define SQL_DISTINCT_NAME "distinct" | |
| #define SQL_VALUE_TYPE_NAME "type" | |
| #define TABLE_REVERSE_NAME "reverse" | #define TABLE_REVERSE_NAME "reverse" |
| // globals | // globals |
| String sql_bind_name(SQL_BIND_NAME); | String sql_bind_name(SQL_BIND_NAME); |
| Line 638 static void _menu(Request& r, MethodPara | Line 645 static void _menu(Request& r, MethodPara |
| } | } |
| #ifndef DOXYGEN | #ifndef DOXYGEN |
| enum Table2hash_distint { D_ILLEGAL, D_FIRST }; | |
| enum Table2hash_value_type { C_HASH, C_STRING, C_TABLE }; | |
| struct Row_info { | struct Row_info { |
| Request *r; | Request *r; |
| Table *table; | Table *table; |
| Line 711 static void table_row_to_hash(Table::ele | Line 720 static void table_row_to_hash(Table::ele |
| key, | key, |
| "duplicate key"); | "duplicate key"); |
| } | } |
| Table2hash_value_type get_value_type(Value& vvalue_type){ | |
| if(vvalue_type.is_string()) { | |
| const String& svalue_type=*vvalue_type.get_string(); | |
| if(svalue_type == "table"){ | |
| return C_TABLE; | |
| } else if (svalue_type == "string") { | |
| return C_STRING; | |
| } else if (svalue_type == "hash") { | |
| return C_HASH; | |
| } else { | |
| throw Exception(PARSER_RUNTIME, | |
| &svalue_type, | |
| "must be 'hash', 'table' or 'string'"); | |
| } | |
| } else { | |
| throw Exception(PARSER_RUNTIME, | |
| 0, | |
| "'type' must be hash"); | |
| } | |
| } | |
| static void _hash(Request& r, MethodParams& params) { | static void _hash(Request& r, MethodParams& params) { |
| Table& self_table=GET_SELF(r, VTable).table(); | Table& self_table=GET_SELF(r, VTable).table(); |
| VHash& result=*new VHash; | VHash& result=*new VHash; |
| Line 769 static void _hash(Request& r, MethodPara | Line 756 static void _hash(Request& r, MethodPara |
| "you can't specify $.distinct[tables] and $.type[] together."); | "you can't specify $.distinct[tables] and $.type[] together."); |
| } else { | } else { |
| valid_options++; | valid_options++; |
| value_type=get_value_type(r.process_to_value(*vvalue_type_code)); | Value& vvalue_type_value=r.process_to_value(*vvalue_type_code); |
| if(vvalue_type_value.is_string()) { | |
| const String& svalue_type=*vvalue_type_value.get_string(); | |
| if(svalue_type == "table"){ | |
| value_type=C_TABLE; | |
| } else if (svalue_type == "string") { | |
| value_type=C_STRING; | |
| } else if (svalue_type == "hash") { | |
| value_type=C_HASH; | |
| } else { | |
| throw Exception(PARSER_RUNTIME, | |
| &svalue_type, | |
| "must be 'hash', 'table' or 'string'"); | |
| } | |
| } | |
| } | } |
| } | } |