使用Medoo如何回应select查询中的值,这是我正在使用文档中的示例进行的操作。
$data = $database->select('names', [
'name','nameId'
], [
'nameId' => 50
]);
echo json_encode($data);
结果是:
[{"name":"Allen","nameId":"50"}]
如何在没有json_encode的情况下回复每一个?
我试过了:
$data['name']
但这不起作用。
答案 0 :(得分:2)
循环并打印。
foreach ($data as $row) {
// echo code here...
// echo $row['name'];
}
答案 1 :(得分:2)
If it's one row you're looking to fetch, use Get instead of Select
$names = $db->get('names',['name','nameId'],['nameId'=>50]);
then use
$name = $names['name'];
$nameId = $names['nameId'];
although you don't need the nameId since your condition is based on it so simply:
$name = $db->get('names','name',['nameId'=>50]);