That script returns "No rows found."
....
Based on my lay knowledge of php, I can't imagine why it doesn't return anything from the script you sent.
#$%&. Me either... though I do have a few ideas...
Is it possible that my installation (default php 5.1 from CentOS 5.x with php-* installed, mysql-* installed, and the add-in json libraries) is different, misconfigured, or missing a dependency? For reference, it already works fine with other popular MySQL/PHP off the shelf applications.
It should work fine. I'm on PHP 5.3.3, but all my code should be compatible with most PHP5 versions (and probably some PHP4 versions too).
To further diagnose this, can you try this script now?
require_once(dirname(__FILE__) . '/common.inc.php');
header('Content-Type: text/plain');
$pdo = db_connect();
function try_query($sql, $args) {
global $pdo;
$q = $pdo->prepare($sql);
if ($q === FALSE) {
return "Could not prepare statement (" . var_export($pdo->errorInfo(), true) . ")";
}
$result = $q->execute($args);
if (!$result) {
return "Could not execute statement (" . var_export($q->errorInfo(), true) . ")";
}
$row = $q->fetch();
if ($row === FALSE) {
return "No rows found";
}
$q->closeCursor();
return "Success (" . var_export($row, true) . ")";
}
$queries = array(
array('name' => 'original',
'args' => array(':worker_id' => 1,
':data' => '000000015bb9a0f983558324beead35e719c4e1e4f3e3d0a8f6550bb00003a5e0000000035cfac9a5865f1e5500714aa46e327a3727fd5a481f0b708820f794f6e0dada84dc4e4f11b0098fa'),
'query' => '
SELECT
p.id AS pool_id,
wp.pool_username AS username,
wp.pool_password AS password,
p.url AS url
FROM
work_data d,
worker_pool wp,
pool p
WHERE d.data = :data
AND d.worker_id = :worker_id
AND d.pool_id = p.id
AND wp.worker_id = :worker_id
AND wp.pool_id = p.id
'),
array('name' => 'hardcoded',
'args' => array(),
'query' => "
SELECT
p.id AS pool_id,
wp.pool_username AS username,
wp.pool_password AS password,
p.url AS url
FROM
work_data d,
worker_pool wp,
pool p
WHERE d.data = '000000015bb9a0f983558324beead35e719c4e1e4f3e3d0a8f6550bb00003a5e0000000035cfac9a5865f1e5500714aa46e327a3727fd5a481f0b708820f794f6e0dada84dc4e4f11b0098fa'
AND d.worker_id = 1
AND d.pool_id = p.id
AND wp.worker_id = 1
AND wp.pool_id = p.id
"),
array('name' => 'nodup',
'args' => array(':worker_id' => 1,
':worker_id_two' => 1,
':data' => '000000015bb9a0f983558324beead35e719c4e1e4f3e3d0a8f6550bb00003a5e0000000035cfac9a5865f1e5500714aa46e327a3727fd5a481f0b708820f794f6e0dada84dc4e4f11b0098fa'),
'query' => '
SELECT
p.id AS pool_id,
wp.pool_username AS username,
wp.pool_password AS password,
p.url AS url
FROM
work_data d,
worker_pool wp,
pool p
WHERE d.data = :data
AND d.worker_id = :worker_id
AND d.pool_id = p.id
AND wp.worker_id = :worker_id_two
AND wp.pool_id = p.id
'),
array('name' => 'no underscore',
'args' => array(':workerid' => 1,
':data' => '000000015bb9a0f983558324beead35e719c4e1e4f3e3d0a8f6550bb00003a5e0000000035cfac9a5865f1e5500714aa46e327a3727fd5a481f0b708820f794f6e0dada84dc4e4f11b0098fa'),
'query' => '
SELECT
p.id AS pool_id,
wp.pool_username AS username,
wp.pool_password AS password,
p.url AS url
FROM
work_data d,
worker_pool wp,
pool p
WHERE d.data = :data
AND d.worker_id = :workerid
AND d.pool_id = p.id
AND wp.worker_id = :workerid
AND wp.pool_id = p.id
')
);
foreach ($queries as $query) {
echo $query['name'];
echo ': ';
echo try_query($query['query'], $query['args']);
echo "\n";
}
?>
Also sent you 5 BTC to the address in your signature for all the work you're putting in; this is in addition to my previous commitment to send you 10 when it appears that this works and is viable. Thanks again for your help.
Cool, thanks! Hopefully we can get this working soon. Obscure bugs are annoying.