php pdo result code example
Example 1: php pdo connection
$host = "localhost";
$user = "root";
$pass = "qwerty";
$dbname = "DB";
try {
$connection = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}catch(PDOException $e)
{
echo $e->getMessage();
}
Example 2: php pdo has result
<?php
$del = $dbh->prepare('DELETE FROM fruit');
$del->execute();
print("Return number of rows that were deleted:\n");
$count = $del->rowCount();
print("Deleted $count rows.\n");
?>