Re: Problems using PDO_MYSQL with MySQL3

From: Date: Fri, 24 Mar 2006 14:38:12 +0000
Subject: Re: Problems using PDO_MYSQL with MySQL3
References: 1 2 3 4 5  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3655@lists.php.net to get a copy of this message
Hi, "Uknown command" comes from the server (ER_UNKNOWN_COM_ERROR) PDO sends a command which is not implemented in 3.23 it's not a query but some COM like COM_PING and so on. The server returns ER_UNKNOWN_COM_ERROR. To trace this you need debug build of the 3.23 server with activated debug trace log or debug build of PHP with PDO to trace and see what is being sent. It's possible that the libmysql sends a command unknown to 3.23 thus confusing the server. Andrey Andreas Korthaus wrote:
Richard Thomas wrote:
Ahh but the pdo libraries make full use of the various features if they exist, chances are PDO is trying to access bind and other features not found in MySQL 3
But I don't use any of the features, only a simple PDO::query(). PDO Manual states: "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." from: http://php.net/pdo-mysql If I accidentally use something MySQL3 does not support, I'd expect PDO to throw an error/exception. I don't get any error, only PDO::query() returns FALSE. The signature of PDO::query() looks like that: PDOStatement PDO::query ( string statement ) So it should return a PDOStatement object, the manual says nothing about a possible boolean return value. Only a comment in http://php.net/pdo-query says: "When query() fails, the boolean false is returned." I really don't understand what's going wrong here. If I added the line var_dump($dbh->errorInfo()); after $dbh->query(), I get: array(3) { [0]=> string(5) "00000" [1]=> int(1047) [2]=> string(15) "Unknown command" } What does "Unknown command" mean? Here is the current test-script: <?php try { $dbh = new PDO('mysql:host=localhost;dbname=test', 'user', 'pass'); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = 'SELECT * FROM test'; $result = $dbh->query($sql); var_dump($result); var_dump($dbh->errorInfo()); $row = $result->fetch(); var_dump($row); } catch(PDOException $e){
    die($e->getMessage());
} ?> The table structure: CREATE TABLE test ( id int(11) unsigned NOT NULL auto_increment, name varchar(32) NOT NULL default '', PRIMARY KEY (id) ) ENGINE=MyISAM AUTO_INCREMENT=3 ; INSERT INTO test (id, name) VALUES (1, 'foo'), (2, 'bar'); Why doesn't PDO throw an exception here? Why does query() return FALSE? What is the "unknown command"? "SELECT * FROM test" looks not very complicated to me ;-) best regards Andreas


« previous php.pecl.dev (#3655) next »