# command line version of cato #$table_field_names = $mdb->listTableFields($tablename); # now i get the field names from the form that is submitted to us $table_field_names =& $fields; $nfields = count($table_field_names); # need to issue a query against the desired table to get the metadata $query = "SELECT * FROM {$tablename}"; # on success this returns an MDB2_Result handle # TODO - deal with the failure condition here #$result = $mdb->query($query, true, true, 'MDB2_BufferedIterator'); $result =& $mdb->query($query, true, true); # now that we have a result set, we can get the field types # as an array: $dt = new DatabaseTable(); $dt->set_raw_table_name($tablename); $dt->set_tablename_prefix($tablename_prefix); $dt->set_raw_field_names($table_field_names); $dt->set_db_field_types($result->types); # assign all the smarty variables we support $smarty->assign('classname', $dt->get_camelcase_table_name()); $smarty->assign('objectname', $dt->get_java_object_name()); $smarty->assign('tablename', $tablename); $smarty->assign('tablename_no_prefix', $dt->get_table_name_no_prefix()); $smarty->assign('tablename_no_prefix_singular', $dt->get_table_name_no_prefix_singular()); $smarty->assign('fields', $table_field_names); $smarty->assign('camelcase_fields', $dt->get_camelcase_field_names()); $smarty->assign('fields_as_insert_csv_string', $dt->get_fields_as_insert_stmt_csv_list()); $smarty->assign('prep_stmt_as_insert_csv_string', $dt->get_prep_stmt_insert_csv_string()); $smarty->assign('prep_stmt_as_update_csv_string', $dt->get_fields_as_update_stmt_csv_list()); $smarty->assign('types', $dt->get_java_field_types()); $smarty->assign('db_types', $dt->get_db_field_types());