CSV file from MySQL using PHP with a OOP aproach (mysqli->connect, etc.)
问题 I'm trying to create a csv file direct from a mysql table using php with an OOP approach. Here is my code: $mysqli = new mysqli($host, $user, $pass, $database); // Checking connection. if ($mysqli->connect_errno) { printf("Connect failed: %s\n", $mysqli->connect_error); exit(); } $query = 'SELECT * FROM table'; $result = $mysqli->query($query); while ($row = $result->fetch_array()) { $rows[] = $row; } $array = ""; foreach($rows as $row) { $array .= "\"".$row["genus"].",".$row["species"]."\","