This Code Works Perfectly For Mysqli
$sql = "SELECT * FROM 'mem_tree' ";
$res = mysqli_query($conn, $sql) or die("database error:".mysqli_error($conn));
while($row = mysqli_fetch_assoc($res)){
$data[] = $row;
}
$itemsByReference = array();
but When i'm trying to do with PDO it Doesn't Work
$sql = "SELECT * FROM 'mem_tree' ";
$stmt = $dbh->prepare($sql);
$stmt->execute();
while($row = $stmt->fetchAll(PDO::FETCH_ASSOC)){
$data[] = $row;
}
$itemsByReference = array();
Here i found Solution of it
$sql = "SELECT * FROM mem_tree";
$stmt = $dbh->prepare($sql);
$stmt->execute();
$final_arr = array();
$data = array();
$final_arr = $stmt->fetchAll(PDO::FETCH_ASSOC);
$data = $final_arr;
$itemsByReference = array();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.