Answer the question
In order to leave comments, you need to log in
How to retrieve data from database with keys?
Guys, how to replace this design?
$data = array();
foreach($stmt->fetchAll() as $val){
$data[$val['id']] = $val;
}
Answer the question
In order to leave comments, you need to log in
Of course, there is such a regime. And of course, he is completely unknown to those who taught pohapa from video courses.
PDO can return data in dozens of different formats, and in particular, index the selection by the first field specified in the request
. If we need a dictionary, then there is a mode for this that returns not nested arrays, but a one-dimensional array, which consists of key-value pairs
$data = $pdo->query("SELECT id, name FROM table")fetchAll(PDO::FETCH_KEY_PAIR);
It seems that there is no ready one, but as an option, use array_column
something like this
but you need to keep in mind that this function behaves differently in php56 and php7
Set Grid.Column and Grid.Row for answers[k]
Grid.SetColumn(answers[k], 0); // Grid.Column = 0
Grid.SetRow(answers[k], 0); // Grid.Row= 0
Try setting the MinWidth and MinHeight values. Perhaps due to the lack of text, the size of the text field = 0.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question