O/H Kazuhiro IIzuka ??????:
Thanks Thodoris.

But this is not things I desired.I've already read php manual and known about PDO::getAttribute() before I post my question.

When I get to server version,I can use $dbh->getAttribute(PDO::
ATTR_SERVER_VERSION),but there are no attribute about mysql server protocol.

I'm planing to make phpMyAdmin-clone with PDO.but I don't know PDO can work instead of mysql/mysqli extension.and I couldn't find equivalent function in PDO with mysql_get_proto_info(mysqli_get_proto_info).

// with mysql extension
$link = mysql_connect($host,$user,$password);
echo mysql_get_proto_info(); // returns 10 in my case.

but I cannot find the proper value like PDO::ATTR_SERVER_PROTOCOL in PDO's getAttribute.

and PDO doesn't seems to use MySQL API's mysql_get_proto_info.

I check like this:
/path/to/php-5.2.4/ext$ grep -r 'mysql_get_proto_info' mysql
mysql/php_mysql.c:      PHP_FE(mysql_get_proto_info,             NULL)
mysql/php_mysql.c:/* {{{ proto int mysql_get_proto_info([int link_identifier])
mysql/php_mysql.c:      RETURN_LONG(mysql_get_proto_info(&mysql->conn));
Binary file mysql/.libs/php_mysql.o matches
/path/to/php-5.2.4/ext$ grep -r 'mysql_get_proto_info' pdo*

I forgot to tell you my environment.

MySQL version: 5.0.27-standard-log
PHP: 5.2.4 (upgrade in near future)
Apache: 2.2.6

You can retrieve some info for the mysql connection (server,driver etc) using PDO::getAttribute()

For e.g. you can do something like that:

  $dbhost = 'localhost';
  $dbuser = 'user_name';
  $dbpass = 'password';
  $db = 'database';

  $dbh= new PDO('mysql:host='.$dbhost.';dbname='.$db, $dbuser, $dbpass);

  echo $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
  echo "<br>";
  echo $dbh->getAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE);
  echo "<br>";
  echo $dbh->getAttribute(PDO::ATTR_SERVER_VERSION);
  echo "<br>";
  echo $dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS);

Well Kazuhiro you should know that PDO is not exactly an alternative for mysql/mysqli but it was supposed to abstract the database details under an object. This is not totally yet happening but I think that you can use PDO instead of mysql/mysqli in any case. Well I have wrote many projects using it, and I think that if I wished to change the database from mysql to some other it would take just few changes in my code.

You can always post this in the developers list if you want more details on the matter and find out if any protocol attributes are to be supported.

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to