try {
$dbh = new PDO("mysql:host=$host;dbname='название_базы'", 'имя_пользователя', 'пароль');
} catch(PDOException $e) {
echo "Нет соединения с базой данных";
}
$user_id = 'id_нужной_записи';
$user = $dbh->prepare("SELECT name FROM users WHERE id = :user_id");
$user->execute(array('user_id' => $user_id))->fetch(PDO::FETCH_OB);
if($user) echo $user->name;
else echo 'Пользователь не найден.'
INSERT INTO wc_terms (id, name, slug) VALUES
(1, 'value', 'value'),
(2, 'value', 'value'),
(3, 'value', 'value')
ON DUPLICATE KEY UPDATE slug = VALUES(slug) + 1;
SELECT event.title, event.url, event.date, type.name as type_name, tournament.name as tournament_name, team1.name AS team1_name, team2.name AS team2_name
FROM events event
LEFT JOIN types type ON event.type_id = type.id
LEFT JOIN tournaments tournament ON event.tournament_id = tournament.id
LEFT JOIN members team1 ON event.member_1_id = team1.id
LEFT JOIN members team2 ON event.member_2_id = team2.id
ORDER BY event.date