I have asked this question before but I haven't got an answer, so I'm rephrasing it.
I want to back up a db using either:
system("mysqldump -h DB_HOST -u DB_USER -p DB_PASS logindb > $location/$backup");
or:
sql="BACKUP my_db TO DISK my_backup_folder WITH FORMAT #";
if ($stmt = $this->connect->prepare($sql)) {
$stmt->execute();
$stmt->close();
} else {
$error = true;
$message['error'] = true;
$message['message'] = CANNOT_PREPARE_DATABASE_CONNECTION_MESSAGE;
return json_encode($message);
}
But the first gives me an empty sql file and the second gives me nothing. Why is that, and if there is a way to find out what error occurred how would I do it ?
Also which method is better ?