Welcome Guest, Not a member yet? Register   Sign In
lack of results when querying db with CI
#1

[eluser]aeternuslibertas[/eluser]
hi all Im running this query through phpMyAdmin
Code:
SELECT *
FROM  `cities_extended`
WHERE  `city` LIKE  "%oak p%"
LIMIT 0 , 30
I end up getting 8 rows.

However when I implement the same thing with codeigniter I get 0 results...

Code:
$search = 'oak p';
$sql = "SELECT * FROM cities_extended WHERE city LIKE '%".$this->db->escape_like_str($search)."% ' GROUP BY city";

$city_suggestions = $this->db->query($sql);
echo($city_suggestions->num_rows);// 0
Whats going on here? :/ can anybody help?
#2

[eluser]aquary[/eluser]
check if $this->db->last_query() show the same query like the first one, else, something is wrong with your code :-)
#3

[eluser]aeternuslibertas[/eluser]
I found the error...
since I have multiple entries for arbitrary rows of cities due to their varied coordinates I decided to use
Code:
GROUP BY city
but its counter productive when using it with the LIKE statement...




Theme © iAndrew 2016 - Forum software by © MyBB