2 つの php オブジェクトがあるとします。
<?php
class Post {
    public $id;
    public $text;
    public $user_id;
}
?>
と
<?php
class User {
    public $id
    public $name
}
?>
すべての投稿には、データベース内の 1 人のユーザーに対する一意の制約があります。
すべての「投稿」属性に対して機能する PDO の「FETCH_CLASS」メソッドを使用して「投稿」オブジェクトにデータを入力したいのですが、「ユーザー」に属性を入力するにはどうすればよいですか?
私のSQL文は次のようになります。
SELECT post.id, 
       post.text, 
       post.user_id, 
       user.id, 
       user.name 
FROM POST INNER JOIN User on post.user_id = user.id
ありがとう!
アップデート:
ATM 「Post」クラスに次のように入力します。
    $statement = $db -> prepare($query);
    $statement -> execute();
    $statement -> setFetchMode(PDO::FETCH_CLASS, 'Post');
    $posts = $statement -> fetchAll();
では、他のクラス「ユーザー」も埋めるためにそれをどのように変更する必要がありますか?
解決:
$statement = $db -> prepare($query);
$statement -> execute();
$posts = array();
while (($row = $statement->fetch(PDO::FETCH_ASSOC)) !== false) {
    $post           = new Post();
    $post->id       = $row['post_id'];
    $post->text     = $row['post_text'];
    $post->created  = $row['post_created'];
    $post->image    = $row['post_image'];
    $post->url      = $row['post_url'];
    $post->weight   = $row['post_weight'];
    $post->likes    = $row['post_likes'];
    $user           = new User();
    $user->id       = $row['user_id'];
    $user->nickname = $row['user_nickname'];
    $user->created= $row['user_created'];
    $user->locked   = $row['user_locked'];
    $post->user     = $user;
    $posts[] = $post;
}
return $posts;