Welcome Guest, Not a member yet? Register   Sign In
Query binding and the question mark
#1

[eluser]Unknown[/eluser]
I am trying to use query binding but I am running into a problem because one of my field names has a question mark in it. I know the correct approach would be to go back and rename the field, however, this is not an option for me.

Is there any way that I can modify this SQL INSERT statement to properly escape the question mark in this field:
Code:
`Paid?`

Here is the SQL:

Code:
$sql = "INSERT INTO `tblAppeals`
(
`#`,
`Year`,
`Property#`,
`Paid?`,
`Outcome`,
`ResolvedBy`,
`AppealCategory`
)
VALUES (?,?,?,?,?,?,?)";

What seems to be happening is that whatever process is handling the bind parameters is also eagerly trying to change all of the
Code:
?
in the SQL and not just what is in the values part of the clause.

EDIT:

I think I have figured out a workaround. I can structure the insert as follows and it works:
Code:
$data = array('#'  => $aID,
  'Year'   => $aYear,
  'Property#'   => $aRoll,
  'Paid?'          => $aPaid,
  'Outcome'   => $aOutcome,
  'ResolvedBy'   => $aResolvedBy,
  'AppealCategory'  => $aCat);

$result = $this->db->insert_string('tblAppeals', $data);

If anyone has any better ideas, please let me know. Thanks.




Theme © iAndrew 2016 - Forum software by © MyBB