前提・実現したいこと
下記mysqliのbind_resultによる変数へのバインドをPDOでも実行したい。
PHP
1 $sql = "select a.id, a.name, a.picture, a.user_id, a.create_at, u.name, u.picture from animals a, users u where u.id=a.user_id order by id desc"; 2 3 $stmt = $db->prepare($sql); 4 if (!$stmt) { 5 die($db->error); 6 } 7 8 $success = $stmt->execute(); 9 if (!$success) { 10 die($db->error); 11 } 12 13 $stmt->bind_result($id, $a_name, $a_picture, $user_id, $a_create_at, $name, $picture);
発生している問題・エラーメッセージ
PDOのfetchで結果を取得するとanimalsテーブルのレコードしか取得できず、usersのレコードが取得できない。
そのため、下記のように結果を配列から取り出すしかない。
php
1$result = $stmt->fetch(); 2 3#結果の表示 4echo $result[0] 5
変数としてバインドする方法はPDOにはないのでしょうか?

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。