Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to retrieve field name from query ? #6

Closed
Rockvole opened this issue Feb 26, 2019 · 1 comment
Closed

How to retrieve field name from query ? #6

Rockvole opened this issue Feb 26, 2019 · 1 comment

Comments

@Rockvole
Copy link

Hi,
Thank-you for your work on this library.

I am trying to retrieve the field name returned from the query method, but having no luck.
e.g.

_conn.query(sql).then((Results results) {
  for(Row row in results) {
    int i=0;
    print("Row="+row.toString());
    row.forEach((v) {
      print("value="+v.toString());
    });
  }
});

I would like to retrieve item_description & item_complete from here :

SELECT              item_description,             item_complete     FROM task_item WHERE task_id = 1
Row=Fields: {item_description: Walk to shops, item_complete: 1}
value=Walk to shops
value=1

And Tables_in_sharecal (task_item) from here :

SHOW TABLES LIKE 'task_item'
Row=Fields: {Tables_in_sharecal (task_item): task_item}
value=task_item

I tried various methods (such as map / asMap) but they didnt return the keys / field names.

@adamlofts
Copy link
Owner

You should be able to use results.fields documented here: https://pub.dartlang.org/documentation/mysql1/latest/mysql1/Results/fields.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants