Named Variable Binding in PDO in PHP

Similarly, you can perform named variable binding via bindValue. Let's see how it's done. Suppose we have the following variables:

php<?php
  $name = 'user';
  $age  = 25;
?>

Suppose we also have named placeholders:

php<?php
  $sql = 'SELECT * FROM users WHERE name=:name or age=:age';
  $res = $pdo->prepare($sql);
?>

Let's bind variables to these placeholders. To do this, the first parameter of the bindValue method should specify the names of the placeholders:

php<?php
  $res->bindValue('name', $name, PDO::PARAM_INT);
  $res->bindValue('age',  $age,  PDO::PARAM_STR);
?>
Задание 1

Given variables:

php<?php
  $name1 = 'name1';
  $name2 = 'name2';
?>

Get users whose name matches the value of the first or the second variable.

Задание 2

Given variables:

php<?php
  $age1 = 21;
  $age2 = 22;
?>

Get users whose age matches the value of the first or the second variable.