0
dbからcsv形式でファイルを展開するときに、各名前の後にカンマが得られます。スクリーンショットをチェックしてください:how the csv file looksJSON_EXTRACTからJSON_EXTRACTのカンマをCSV形式で取り除きます。
は、これはコードです:json_extractは、DB内にあるすべてのユーザーを取っているが、それらが表示されていない、昏睡状態で区切ってちょうど空のスロットと同じよう
function expired(){
if(isset($_POST['download']))
{
$db =& JFactory::getDBO();
$time = (time());
$query = "select user_id, profile_value FROM #__user_metadata WHERE JSON_EXTRACT(profile_value, '$.expiry_date') > '$time'";
$db->setQuery($query);
$rows = $db->loadObjectList();
header('Content-type: text/csv');
ob_end_clean(); // is cleaning the space before the list
header('Content-Disposition: attachment; filename=UserDatabase.csv');
ob_start();
$output = fopen("php://output", "w");
foreach ($rows as $row) {
$user_id = json_decode($row->user_id);
$db =& JFactory::getDBO();
$query = "select user_id, profile_value FROM #__user_metadata WHERE user_id = '$user_id'" ;
$db->setQuery($query);
$rows = $db->loadObjectList();
foreach ($rows as $row) {
$profile_value = json_decode($row->profile_value);
$first_name=$profile_value->first_name;
$last_name=$profile_value->last_name;
$email =$profile_value->email;
$users = array($first_name . " " . $last_name, $email);
fputcsv($output, $users, ',') ;
}
}
fclose($output);
ob_end_flush();
exit(0);
}
}
に見えます問題はその行から来ていません:
fputcsv($output, $users, ',') ;