-1

i want to query something from mysql database and put condition that check equality between a value in the table but after round it and other value also after round it how to do this in php codeigniter ,plz help i put this instruction put it didn't work

$t=round($latitude,4);
$t1=round($longitude,4);    
$this->db->select('place_name');
$this->db->from('place');
$this->db->where(round(`Latitude`,4), $t);
$this->db->where(round(`Longitude`,4),$t1);
$q = $this->db->get();
4

1 回答 1

2

You need to quote the round call, because right now you're trying to execute a PHP round() function, not the SQL one:

$this->db->where('round(`Latitude`,4)', $t);
                 ^--                 ^--

quoting it turns the whole thing into a string, which gets passed into the DB.

于 2013-07-10T18:23:59.713 回答