![]() |
how to call mysql procedures in php???
Hi there ,
did you know, how to call mysql procedures in php?? searched on google then find PDO class library - but don't know how to use. I m new to PHP, please reply ASAP. |
PHP: MySQL - Manual
essentially if you just want to get back an array of items from the database PHP Code:
PHP Code:
Though you might want to look up mysqli - or have someone speak of it, I'm not very learned with it. The aforementioned class. PHP Code:
|
Hmmm. Did you not mean stored procedures?
|
Yes i mean Stored Procedures in mysql
Yes i mean Stored Procedures in mysql
|
Isn't it something like this? I forget now. It's a while since I used stored procedures.
php Code:
|
yes saw in many examples but not working
1 Attachment(s)
i even tried mysqli functions but not working. then i found PDO class but PDO Connection class not working.. don't know where is the problem.
Have a look to the attached zip file, including PDO connection class but not working. |
Using PDO you can work along the lines of:
PHP Code:
|
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(); } |
| All times are GMT. The time now is 05:37 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0