note 69592 added to ref.pdo-mysql
| From: | dibakar at talash dot net | Date: | Tue, 12 Sep 2006 06:31:46 +0000 |
| Subject: | note 69592 added to ref.pdo-mysql | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117044@lists.php.net to get a copy of this message | ||
PDO is much better option for calling procedures, views or triggers of mysql 5.x versions from PHP
instead of using mysqli extension. Following is a simple demo script which can help anybody on how
to call and use mysql procedures through php
try {
$dbh = new PDO('mysql:host=xxx;port=xxx;dbname=xxx', 'xxx', 'xxx',
array( PDO::ATTR_PERSISTENT => false));
$stmt = $dbh->prepare("CALL getname()");
// call the stored procedure
$stmt->execute();
echo "<B>outputting...</B><BR>";
while ($rs = $stmt->fetch(PDO::FETCH_OBJ)) {
echo "output: ".$rs->name."<BR>";
}
echo "<BR><B>".date("r")."</B>";
} catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
----
Server IP: 203.199.107.94
Probable Submitter: 125.22.48.141
----
Manual Page -- http://www.php.net/manual/en/ref.pdo-mysql.php
Edit -- https://master.php.net/note/edit/69592
Del: integrated -- https://master.php.net/note/delete/69592/integrated
Del: useless -- https://master.php.net/note/delete/69592/useless
Del: bad code -- https://master.php.net/note/delete/69592/bad+code
Del: spam -- https://master.php.net/note/delete/69592/spam
Del: non-english -- https://master.php.net/note/delete/69592/non-english
Del: in docs -- https://master.php.net/note/delete/69592/in+docs
Del: other reasons-- https://master.php.net/note/delete/69592
Reject -- https://master.php.net/note/reject/69592
Search -- https://master.php.net/manage/user-notes.php