Question about mysql-d Object

Daniel Kozak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Dec 7 08:11:19 PST 2015


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"]);}
>
> I only get the output of the first loop (50 lines), probably 
> this is a feature
> not a bug, but what kind of Object is rows?
>
> 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?
>
> Sorry, but I am very new on D, (it may be the best language 
> available, I don't know yet, but it is really the most 
> interesting!) thank you!

what if you make array from it:
import std.array: array;
auto rows = mysql.query("select field from my_table limit 
50").array;



More information about the Digitalmars-d-learn mailing list