I am new to zend framework and i am having a problem while i was trying to add items into an array.
first i created a db table object:
$questionTable = new xxx();
$db = $questionTable->getAdapter();
$sql = "select * from questions where value='v'";
$res = $db->query($sql)->fetchAll();
the $res is an array which looks like this in JSON [{'a':1},{'a':2},{'a':3}]
then i used a foreach :
foreach($res as $element)
{
$value = $element['a'];
if($value == 2)
{
$element['extra'] = 10;
}
}
then when i print out the result using:
echo Zend_Json_Encoder::encode($res);
it remains [{'a':1},{'a':2},{'a':3}].
does anyone know how to fix it?
thx in advance:)