(1)
<?php
$dbh= new PDO('mysql:host=$host; dbname=$database;', $user, $pass);
$data = $dbh->prepare("SELECT name, city FROM info");
$data->execute(); print("get all of the remaining rows in the result set:\n");
$result = $data->fetchAll();
print_r($result);
?>
This is an object oriented php database connectivity with mysql ,its provides best security by
splitting all sql injection issues
(2)
<?php $query->setFetchMode(PDO::FETCH_OBJ);
while($result = $query->fetch()){
print_r($result);
}
?>
In This method its returns StdClass' object you can fetch by -> sign of databse field name
No comments:
Post a Comment