當我做一個查詢到我的數據庫是這樣的結果:mysqli的查詢返回的結構,而不是數據
mysqli_result Object
(
[current_field] => 0
[field_count] => 3
[lengths] =>
[num_rows] => 3
[type] => 0
)
這是我使用的代碼:
$servername = "localhost";
$username = "root";
$password = "";
// Create connection
$conn = new mysqli($servername, $username, $password, 'melona');
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM votacion";
$result = $conn->query($sql);
echo "<pre>";
print_r($result);
echo "</pre>";
die();
當然我不我不想獲取該表,我想獲取表中包含的行,我的代碼有什麼問題?
查詢返回一個結果集,然後您可以在何時,何處以及如何獲取結果集(作爲assoc數組,作爲對象,數字索引數組......),它就是如何工作的,以及它總是如何工作......另外:不要「死」,而是關閉連接,並在完成後釋放資源。這裏不需要_really_,但這是一個好習慣 – 2014-11-14 13:42:06
謝謝,我也應用了你的建議。 – Mariano 2014-11-14 13:53:31