Question about mysql-d Object

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 8 07:14:06 PST 2015


V Tue, 08 Dec 2015 14:34:53 +0000
Martin Tschierschke via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> napsáno:

> On Monday, 7 December 2015 at 16:11:19 UTC, Daniel Kozak wrote:
> > On Monday, 7 December 2015 at 14:40:12 UTC, Martin Tschierschke 
> > wrote:  
> >> When I do the following:
> >>
> >> auto mysql = new Mysql("localhost", 3306, "mt", "", 
> >> "verwaltung");
> >> auto rows = mysql.query("select field from my_table limit 50");
> >>
> >> foreach(row;rows){
> >>  writeln(row["field"]);}
> >>
> >> // second time same loop
> >>
> >> foreach(row;rows){
> >>  writeln(row["field"]);}
> >>  
> [...]
> >> A nested loop, did not worked either:
> >>
> >> foreach(row;rows){
> >>  foreach(field;row){
> >>  writeln(field);}
> >> }
> >>
> >> Which other ways to access the elements of rows do I have?
> >>  
> [...]
> > what if you make array from it:
> > import std.array: array;
> > auto rows = mysql.query("select field from my_table limit 
> > 50").array;  
> Thank you both for your answers!
> This worked, for the first part of my question.
> Now I took a work around, getting the field names in a separate 
> mysql-request,
> but they should be available in the row object, too?
> 

rows.fieldNames() this one is better result type is string[]



More information about the Digitalmars-d-learn mailing list