5

I can't figure this out, and no searching has yielded results.

the query:

$QUERY = "SELECT rp.perm_id 
          FROM ac_br_user-roles AS ur 
          JOIN ac_br_roles-permissions AS rp ON rp.role_id = ur.role_id 
          WHERE ur.user_id = ?";

I have tried using `` backticks '' single quotes and {} curly braces to enclose the table name and \ backslash right at the - to escape the - hyphen all to no avail.

The error:

PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "-" LINE 2: FROM ac_br_user-roles AS ur ^ in

or "at or near" whatever the escape character I try using on LINE 2

UPDATE

$QUERY = 'SELECT rp.perm_id 
          FROM `ac_br_user-roles` AS ur 
          JOIN `ac_br_roles-permissions` AS rp ON rp.role_id = ur.role_id 
          WHERE ur.user_id = ?';

PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "" LINE 2: FROMac_br_user-roles` AS ur ^ in

backticks don't help, same results for both single and double quotes on the $QUERY string.

Chad
  • 1,139
  • 17
  • 41
  • I've been staying in the question and noticed the edit. I added a few more duplicates to consult and moved the first 2 above the others which are more relevant. – Funk Forty Niner Oct 12 '18 at 13:55
  • 3
    I have figured it out now - in my instance I must `" "` double quote the table names, and thus single quote the string. – Chad Oct 12 '18 at 13:57
  • Yes and am glad to hear it Chad :-) Adding the 2 others were more relevant than the original and I apologize for that. – Funk Forty Niner Oct 12 '18 at 13:59

0 Answers0