lol
ok sorry for code complexity, just lemme explain.
The code is intented to bind enough variables as result to be able to fetch a whole row of result dataset.
So I first create an array with keys which are names of the table fields in database.
Then I create another numeric array, and reference every member of it to my first array,
Third I bind_results the fields array. Its like this:
$fields[1]= & $out[ID];
$fields[2]= & $out[Username];
Statement->bind_result($fields[1],$fields[2]);
which is equal to
Statement->bind_result($out[ID],$out[Username]);
So everytime i fetch a row from result set, I get $out array filled with data. And I can access all the fields of the row with their responsive keys.
Now I just want to have a whole result set in a 2D array, So while i have rows to be fetched, I fetch them, And add them to another array:
While( there are rows to fetch )
{
$out=fetchit();
$output[]=$out;
}
in the end, $output should be the desired 2D array i've been looking for.
But unexpectedly, When I do so, $output would be a 2D array with same rows!
e.g my db would contain:
ID Username
1 AbiusX
2 XsuibA
But the output has
[0]=> array([ID]=>2 , [Username]=>XsuibA) , [1] =>array([ID]=>2, [Username]=>XsuibA)
As you see, All data are repeated. I think this is because the $output array holds referenced to $out in every new set, Instead of copies from $out.
So I wanted a method to copy $out into $output[]..
When i surfed the net, the only way to copy an array was to say $a=$b;
but this isnt working for sure in my case, So I used 2 functions to counter each other and get the result, But serialization and deserialization is greatly decreasing the performance here.
Any ideas?
but in a dynamic manner.