Proper way to escape query in Codeigniter

$sql = ("update Inventory SET  ? = ?+1 WHERE ID= ?");

$query = $this->db->query($sql, array($field,$field,$id))->affected_rows();

The error:

You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ”Upvotes’ = ‘Upvotes’+1 WHERE ID= 386464′ at line 1

Basically it’s adding quotes around the Upvotes field causing it to be a malformed query what’s the most practical way to remove the single quotes or rewrite the query entirely?


Download proper.way.to.escape.query.in.codeigniter.zip
Direct Link


Download


Download proper.way.to.escape.query.in.codeigniter.zip
Mediafire


Download


Download proper.way.to.escape.query.in.codeigniter.zip
Gboxes


Download

Both comments and pings are currently closed.

Comments are closed.