如何使用 PDO 在数组中添加一行。以前我是这样做的$message = array('status' => 'ok';
但是当我尝试像这样在 PDO 中使用它时它不起作用
try {
$dbh = new PDO("mysql:host=$dbhost;dbname=$dbname", $dbuser, $dbpass);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->query($sql);
$employees = $stmt->fetchAll(PDO::FETCH_OBJ);
$employees['status'] = 'ok';
$employees = array($employees);
$dbh = null;
header('Content-Type: application/json');
echo '{"key":'. json_encode($employees) .'}';
}