I have problem with FETCH_CLASS. This part of code not displaying any data from my database.
class Names {
public $name, $mail, $city, $entry;
}
$stmt = $db->query('SELECT * FROM data');
$query->setFetchMode(PDO::FETCH_CLASS, 'Names');
while($r = $stmt->fetch()){
print_r($r);
}
Also I have problem with this thing. Nothing happens.
$stmt = $db->query('SELECT * FROM data');
while($r = $stmt->fetch()){
echo $r->message, '<br>';
}
And another question. All this code must be always before execute() function, or can It be after somehow?
Try this for ist query:
$stmt = $db->query('SELECT * FROM data');
$stmt->setFetchMode(PDO::FETCH_CLASS, 'Names');
while($r = $stmt->fetch()){
print_r($r);
}
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.