I want to pull something I query into an array.
SELECT * FROM `x`
There may be 1 result or 1,000 results. The columns will vary, I mean, I'd rather be vague than write a specific interpreter for each query, I'd rather the function determine the column names.
So what do I really want?
<?php
$results = mysql::query("SELECT * FROM x");
$holding = array();
//Now we get the results.
while ($row = mysql_fetch_assoc($results)) $holding[] = $row;
?>
Obviously this is not C#, but I'd like the equivalent. I want all of my results, retaining their column names, in an array so I can call holding[0]["Column"];
My C# code is as follows.
if (connected)
{
MySqlCommand cmd = new MySqlCommand(query, conn);
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read()){
//The problem is here, I don't know how to add them to a list/array retaining column names etc..
}
}