9951 explained code solutions for 126 technologies

php-pdoJoin query example with PHP PDO

$st = $pdo->prepare('SELECT p.*, u.name FROM photos p JOIN users u ON (u.id = p.user_id)');

foreach ( $st as $row ) {
}ctrl + c

prepare given query to execute

p.*, u.name

selects all columns from photos table and name column from users table


run query on the server

foreach ( $st as $row )

go through each row in result set


print each row