How can I get MySQL protocol information with PDO?
How can I get MySQL protocol information with PDO?
am 30.11.2007 03:02:35 von Kazuhiro IIzuka
Hi All.
Now I'm trying to get MySQL protocol information with PDO.
There are "mysql_get_proto_info" and "mysqli_get_proto_info" to get
MySQL protocol information.
But PDO_MySQL doesn't seems to support this feature.
If I mistake,please let me know.and How to get MySQL protocol
information with *PDO*.
Thanks,
Kazu.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: How can I get MySQL protocol information with PDO?
am 30.11.2007 08:15:44 von Goltsios Theodore
O/H Kazuhiro IIzuka ??????:
> Hi All.
>
> Now I'm trying to get MySQL protocol information with PDO.
> There are "mysql_get_proto_info" and "mysqli_get_proto_info" to get
> MySQL protocol information.
>
> But PDO_MySQL doesn't seems to support this feature.
> If I mistake,please let me know.and How to get MySQL protocol
> information with *PDO*.
>
> Thanks,
> Kazu.
>
Although I have never used other methods to access mysql but PDO and I
am not sure what you mean. This could be the answer:
http://www.php.net/manual/en/ref.pdo-mysql.php
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 "
";
echo $dbh->getAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE);
echo "
";
echo $dbh->getAttribute(PDO::ATTR_SERVER_VERSION);
echo "
";
echo $dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS);
?>
In order to find out driver details like the driver name, buffer size,
mysql version and connection status. A list of some of the the
attributes can be found in the link above or in the section of
Predefined Constants list in:
http://www.php.net/manual/en/ref.pdo.php
--
Thodoris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: How can I get MySQL protocol information with PDO?
am 30.11.2007 09:52:39 von 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:PHP_FUNCTION(mysql_get_proto_info)
mysql/php_mysql.c: RETURN_LONG(mysql_get_proto_info(&mysql->conn));
mysql/php_mysql.h:PHP_FUNCTION(mysql_get_proto_info);
Binary file mysql/.libs/php_mysql.o matches
/path/to/php-5.2.4/ext$ grep -r 'mysql_get_proto_info' pdo*
/path/to/php-5.2.4/ext$
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 "
";
> echo $dbh->getAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE);
> echo "
";
> echo $dbh->getAttribute(PDO::ATTR_SERVER_VERSION);
> echo "
";
> echo $dbh->getAttribute(PDO::ATTR_CONNECTION_STATUS);
>?>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: How can I get MySQL protocol information with PDO?
am 30.11.2007 11:23:10 von Goltsios Theodore
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:PHP_FUNCTION(mysql_get_proto_info)
> mysql/php_mysql.c: RETURN_LONG(mysql_get_proto_info(&mysql->conn));
> mysql/php_mysql.h:PHP_FUNCTION(mysql_get_proto_info);
> Binary file mysql/.libs/php_mysql.o matches
> /path/to/php-5.2.4/ext$ grep -r 'mysql_get_proto_info' pdo*
> /path/to/php-5.2.4/ext$
>
> 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 "
";
>> echo $dbh->getAttribute(PDO::MYSQL_ATTR_MAX_BUFFER_SIZE);
>> echo "
";
>> echo $dbh->getAttribute(PDO::ATTR_SERVER_VERSION);
>> echo "
";
>> 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.
--
Thodoris
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php