06-05-2008, 08:13 PM
|
#8 (permalink)
|
|
The Wanderer
Join Date: Jun 2008
Posts: 8
Thanks: 2
|
in PDO Connection class, functions not shows any result.
Yes this simple code is working for me, but in PDO Connection class, functions not shows any result.
try {
$dbh = new PDO("mysql:host=localhost;dbname=example", "root", "root");
/*** echo a message saying we have connected ***/
echo 'Connected to database<br />';
/*** The SQL SELECT statement ***/
$sql = "CALL myprocedure(parameters)";
/*** fetch into an PDOStatement object ***/
$stmt = $dbh->query($sql);
/*** echo number of columns ***/
$result = $stmt->fetch(PDO::FETCH_NUM);
/*** loop over the object directly ***/
foreach($result as $key=>$val)
{
echo $key.' - '.$val.'<br />';
}
/*** close the database connection ***/
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}
Last edited by gptArun : 06-05-2008 at 08:15 PM.
Reason: in $sql = "query or calling procedure" works
|
|
|
|