• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I remove single quote from query?

#1
[eluser]veledrom[/eluser]
Hi,

How can I remove single quote from query?

Thanks

Code:
$sql = ".........ORDER BY Distance ASC LIMIT ? OFFSET ?";
$this->db->query($sql, array($limit, $offset));

- Generated as:
Code:
ORDER BY Distance ASC LIMIT '10' OFFSET 0
- Should be:
Code:
ORDER BY Distance ASC LIMIT 10 OFFSET 0


#2
[eluser]Learn CodeIgniter[/eluser]
Use Active Record
Note: If you are selecting all (*) from a table you do not need to use this function. When omitted, CodeIgniter assumes you wish to SELECT *

$this->db->select() accepts an optional second parameter. If you set it to FALSE, CodeIgniter will not try to protect your field or table names with backticks. This is useful if you need a compound select statement.
Code:
$this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
$query = $this->db->get('mytable');

#3
[eluser]fivefinger-bd[/eluser]
Use like this

Code:
$sql = ".........ORDER BY Distance ASC LIMIT ? OFFSET ?";
$this->db->query($sql, array(intval($limit), $offset));

#4
[eluser]veledrom[/eluser]
I'll try. Thanks

Noticed one thing though. Singe quotes are being add automatically in Windows environment. Without extra bits, it works fine in Linux environment. As usual, Linux wins again!!!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.