I have a very simple select query that I know should return a value, but it never does. Can anyone help me with this one? I’ve been stuck for ages.
I know the database connection works, since I write to the database a few lines further down, which works fine.
$row is set to false when fetchObject() fails, but I can not for the life of me work out why it fails It’s probably simple, and I’m probably blind, but oh so annoying
I’m using mysql
code:
$statement = $DbConn->prepare("SELECT id FROM mineral_index WHERE typeID = :typeID AND systemID = :systemID");
$statement->bindParam('typeID', $this->typeID, PDO::PARAM_INT);
$statement->bindParam('systemID', $this->systemID, PDO::PARAM_INT);
$row = $statement->fetchObject();
echo "<p><pre>";
$statement->debugDumpParams();
var_dump($statement->errorInfo());
var_dump($this->typeID);
var_dump($this->systemID);
var_dump($row);
echo "</pre></p>";
dump:
SQL: [76] SELECT id FROM mineral_index WHERE typeID = :typeID AND systemID = :systemID
Params: 2
Key: Name: [7] :typeID
paramno=-1
name=[7] ":typeID"
is_param=1
param_type=1
Key: Name: [9] :systemID
paramno=-1
name=[9] ":systemID"
is_param=1
param_type=1
array(3) {
[0]=>
string(5) "00000"
[1]=>
NULL
[2]=>
NULL
}
int(35)
int(30000142)
bool(false)
Thanks a bunch