PDO exception in JOIN query
I've been on this all morning and I can't figure out why it's not working.
$spn = '20275096';
$dbh = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};
Dbq=".realpath('exported/test1.mdb')."; Uid=Admin");
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $dbh->prepare(" SELECT Cup_PartUpdateCommodityID FROM
Cup_PartUpdateCommodity INNER JOIN Cup_PartUpdateInfo ON
[Cup_PartUpdateCommodity].Cup_PartUpdateCommodityID =
[Cup_PartUpdateInfo].Cup_PartUpdateCommodityID INNER JOIN Cup_PartUpdate
ON [Cup_PartUpdateInfo].Cup_PartUpdateID =
[Cup_PartUpdate].Cup_PartUpdateID WHERE [Cup_PartUpdate].PartNum =
:partnum ");
$stmt->bindParam(':partnum', $spn);
$stmt->execute();
$row = $stmt->fetch();
echo $row['Cup_PartUpdateCommodityID'];
It throws the following error:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: -3100 [Microsoft][ODBC
Microsoft Access Driver] Syntax error (missing operator) in query
expression '[Cup_PartUpdateCommodity].Cup_PartUpdateCommodityID =
[Cup_PartUpdateInfo].Cup_PartUpdateCommodityID INNER JOIN Cup_PartUpdate
ON [Cup_PartUpdateInfo].Cup_PartUpdateID =
[Cup_PartUpdate].Cup_PartUpdateID'. (SQLExecute[-3100] at
ext\pdo_odbc\odbc_stmt.c:254)' in C:\sites\myproject\test.php:31 Stack
trace: #0 C:\sites\myproject\test.php(31): PDOStatement->execute() #1
{main} thrown in C:\sites\myproject\test.php on line 31
Note: The code above will be executed in a function that expects $spn as a
parameter. Just for now I'm setting a default value for $spn. Anyone?
No comments:
Post a Comment