I am calling the query function from cakephp, and I am selecting two fields from the database. How do I access each field from the array? The query is as such
$fieldKeys = $this->query("select FLOWSHEET_NAME, FLOWSHEET_ID from FLOWSHEET_TEMPLATE");
And I want to do something along the lines of:
foreach($fieldKeys as $value){
foreach($value as $nest){
foreach($nest as $id){
$mapArray[$id[0]] = $id[1];
}
}
}
But this doesn’t work.
This works but $id[0] only gives back the first letter of the string held in the FLOWSHEET_NAME column, whereas I want the whole string.
Cake gives you tools to inspect the array and see for yourself. These tools are
pr($varname)anddebug($varname), but there are other non-cake functions as well.This is not really a cake question, it’s an elementary programming class question.