LXXXV. MySQL Functions (PDO_MYSQL)

简介

警告

本扩展模块是实验性的。本模块的行为,包括其函数的名称以及其它任何关于此模块的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本扩展模块风险自担。

PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL 3.x and 4.x databases.

目录
PDO_MYSQL DSN -- Connecting to MySQL databases

add a note add a note User Contributed Notes
dibakar at talash dot net
12-Sep-2006 02:31
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();
   }