How can i change the array name gotten from the database : for example
If i print this json_encode($rows)
I have :
{"access":"MTAPI"}
But, in the Json format, i want "access" to be called "Type".
How may i achieve this ?
Secondly, how may i push more data into the array to appear as such :
{"access":"MTAPI", "alias":"result"}
I tried but it's messy:
array_push($rows, "alias", "result");
Thirdly, if i have a whole structure will multiple sql statements that i need to perform to built it, should i use a giant array, fit everything in then pass to json_encode ? or does json_encode do some kind of concatenation ?
The array of $row
$sth = $dbh->query("SELECT access FROM NodeAttributes WHERE Node_ID = '$nodeid[$i]'")or die(mysql_error());
$rows = array();
while($r = $sth->fetch(PDO::FETCH_ASSOC)) {
$rows[] = $r;
}