Q:

Strange MySQL result set for REGEXP executed via PHP

I have MySQL table with the following structure:
+---------+--------------+------+-----+---------+----------------+
| Field   | Type         | Null | Key | Default | Extra          |
+---------+--------------+------+-----+---------+----------------+
| id      | int(11)      | NO   | PRI | NULL    | auto_increment |
| dept    | varchar(5)   | NO   | MUL |         |                |
| sudoc   | varchar(255) | NO   |     |         |                |
| title   | varchar(255) | NO   |     |         |                |
| type    | tinyint(1)   | NO   |     | 0       |                |
| date    | date         | NO   | MUL |         |                |
| comment | mediumtext   | NO   |     |         |                |
+---------+--------------+------+-----+---------+----------------+

I'm working on a basic search page, which should search the fields "sudoc" and "title" for an arbitrary phrase and return the records that match.
Currently, my database has exactly one record containing the word "Lava" in the title.  When I execute the following SQL manually by typing it in on the MySQL command line, it works fine:
PREPARE test FROM "SELECT * FROM govdocs WHERE LCASE(sudoc) REGEXP ? OR LCASE(title) REGEXP ? ORDER BY sudoc";
SET @a = "Lava";
SET @b = "Lava";
EXECUTE test USING @a, @b;

It returns the one matching record.
But then I execute this PHP:
<?php

$DSN = "mysql:host=db.example.edu;port=3306;dbname=govdocs";
$DB = new PDO($DSN, "govdocs", "password", array(PDO::ATTR_PERSISTENT => true));

$SQL = "SELECT * FROM govdocs WHERE LCASE(sudoc) REGEXP :phrase ";
$SQL .= "OR LCASE(title) REGEXP :phrase ORDER BY sudoc";

$query = $DB->prepare($SQL);

$query->execute(array(':phrase' => "Lava",));

if($query){
    $results = $query->fetchall(PDO::FETCH_ASSOC);
    print "There are ".count($results)." results.";
} else {
    print $DB->errorInfo();
}

print "\n";

And it returns 236 results.  The "Lava" record is not one of them.
I've tried it with other phrases, and the results are not at all consistent.

A search for any single-letter character returns seemingly sane results
A search for any TWO characters returns 238 results, give or take 5
A search for any THREE OR MORE characters returns 236 results

As far as I can tell, the SQL works just fine when I do it manually on the database server.  Things get wonky only when it's executed by PHP.
At this point, I have no idea what's going on. What am I missing?
EDIT:
Here's a new test case which tries a query from PHP without bound parameters, as suggested by QTax:
<?php

$DSN = "mysql:host=db.example.edu;port=3306;dbname=govdocs";
$DB = new PDO($DSN, "govdocs", "password", array(PDO::ATTR_PERSISTENT => true));

// First, do it with a static query -- no bound parameters.
$SQL = "SELECT * FROM govdocs WHERE LCASE(sudoc) REGEXP 'Lava' ";
$SQL .= "OR LCASE(title) REGEXP 'Lava' ORDER BY sudoc";

$Query = $DB->prepare($SQL);
$Query->execute();

$results = $Query->fetchall(PDO::FETCH_ASSOC);
print "There are ".count($results)." results for a query with no bound parameters.\n";

// Then do it WITH bound parameters
$SQL2 = "SELECT * FROM govdocs WHERE LCASE(sudoc) REGEXP :phrase ";
$SQL2 .= "OR LCASE(title) REGEXP :phrase ORDER BY sudoc";

$Query = $DB->prepare($SQL2);
$Query->execute(array(':phrase' => "Lava",));

$results = $Query->fetchall(PDO::FETCH_ASSOC);
print "There are ".count($results)." results for a query WITH bound parameters.";

print "\n";

And the output when I run this is:
There are 1 results for a query with no bound parameters.
There are 236 results for a query WITH bound parameters.

There is something weird going on with bound parameters.  I just checked the server's PHP version with php -v, and it said:
PHP 5.1.6 (cli) (built: Nov 13 2010 16:05:12)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

5.1.6 is nearly five years old.  I wonder if this is some kind of ancient bug that's been fixed in newer versions?

A:

Try this:
$sql = "SELECT * FROM govdocs WHERE sudoc REGEXP ? OR title REGEXP ? ORDER BY sudoc";
$param = "Lava";

$query = $DB->prepare($sql);
$query->execute(array($param, $param));

