Best way to fetch multiple variables from MySQL Database using PDO <p>Okai, so I am trying to fetch multiple variables from the MySQL Database using PDO and I feel that I have to repeat myself alot in the code. Is there a neater way to write this or a more secure way?</p> <p>Here is my code for the following example:</p> <pre><code> $username = $_SESSION['username']; $db = new PDO('mysql:xxxxxxxx;dbname=xxxxxxxxxxxx', 'xxxxxx', 'xxxxxxx'); // FETCH name VARIABLE $fetchname = $db-&gt;prepare("SELECT name FROM login WHERE username = :username"); $fetchname-&gt;bindParam(':username', $username, PDO::PARAM_STR, 40); $fetchname-&gt;execute(); $myname = $fetchname-&gt;fetchColumn(); // FETCH age VARIABLE $fetchage = $db-&gt;prepare("SELECT age FROM login WHERE username = :username"); $fetchage-&gt;bindParam(':username', $username, PDO::PARAM_STR, 40); $fetchage-&gt;execute(); $myage = $fetchage-&gt;fetchColumn(); </code></pre> <p>I wish to avoid having to repeat this FETCH for each variable from the same table...</p>