MySQL

How to Get PDO Query Result in PHP

Posted on
The first method is to use the simple query() of PDO to return a statement object, and then fetch the statement object to get the result….$sql = “select * from users where username=’Ed Chen’);$dbh = new PDO(“mysql:host=$hostname;dbname=$dbname”, $user, $pass, $options);$statement = $dbh -> query($sql);$result =  $statement -> fetchAll();var_dump($result);…The advantages of this method is simple and […]