Ben bu comment sınıf yazıyorum:
class Comment {
public $id;
public $post_id;
public $name;
public $email;
public $website;
public $body;
public $date;
public $ip_address;
public $status;
function __construct($id) {
global $db;
$resc = $db->query("SELECT * FROM blog_comments WHERE id='$id' LIMIT 1");
while($row = $db->fetch_assoc($resc)) {
while ($comment = current($row)) {
$key = key($row);
$this->$key = $comment{$key};
next($row);
}
}
}
}
İşte veritabanında çalıştırdığınızda Kurucuların içinde sorgu dönecektir budur:
Bunu çalıştırdığınızda Ama, bu ne print_r olduğunu (yeni Yorum (1)); tükürür:
Comment Object
(
[id] => 1
[post_id] => 1
[name] => J
[email] => j
[website] => h
[body] => b
[date] => 1
[ip_address] => :
[status] => 1
)
Herhangi Ben sadece her alanın ilk karakterini alıyorum neden fikir?
Teşekkürler.