Home Tutorial Php Phppdo Tutorial PDO Fetch Lazy

 
 

Share on Google+Share on Google+
PDO Fetch Lazy
Posted on: April 5, 2010 at 12:00 AM
Advertisement
In this tutorial we will study about PDO Fetch Lazy method in PHP, how to access MySQL using PDO Fetch Lazy method , How to retrieve data etc. Examples will make this clearer.

PDO Fetch Lazy:

PDO::FETCH_LAZY is the combination of PDO::FETCH_OBJ and PDO::FETCH_BOTH. It displays the query which has been made along with the object variable names as they are accessed. Following  example illustrates the idea, and as you see the output, you will find the it displays the query and the field names and their respective values.

Example:

<?php

header('Content-type:text/plain');

$host='localhost';

$user='root';

$password='';

try

{

$dbh=new PDO("mysql:host=$hostname;dbname=ajax",$user,$password);

$sql="select * from student";

$stmt=$dbh->query($sql);

$obj=$stmt->fetch(PDO::FETCH_LAZY);

print_r($obj);

$dbh=null;

}

catch(PDOException $c)

{

echo $c->getMessage();

}

?>

 

Output:

PDORow Object
(
    [queryString] => select * from student
    [name] => neeraj
    [roll] => 2
)
Advertisement

Related Tags for PDO Fetch Lazy:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 5, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com