Welcome Guest, Not a member yet? Register   Sign In
how to see what is behind $query
#1

[eluser]Mitja[/eluser]
Code:
$arg = array();
$arg[] = "arrangement_event = 0";
if($this->input->post('country'))
{
    $country = $this->input->post('country');
    $arg[] = "where_is_country LIKE '%" . $country . "%'";
}
if($this->input->post('city'))
{
    $city = $this->input->post('city');
    $arg[] = "where_is_city LIKE '%" .$city . "%'";
}
$searcharg = implode(" AND ", $arg);

$query = $this->db->query("SELECT * from arrangement_event WHERE $searcharg");

how i can see what is behind $query = $this->db->query("SELECT * from arrangement_event WHERE $searcharg");

Is it possible to see this sql statement that i will se if is everything correct.

Thx
#2

[eluser]Lagarto[/eluser]
You can see the Query with "$this->db->last_query();"
#3

[eluser]walterblaurock[/eluser]
Alternatively, you can simply take the contents of the query, and echo them as opposed to inputting them into the query function. Though not as elegant as the above solution, it can be useful as well. Are you using anything such as PHPMyAdmin that can give you specific feedback as to why a query isn't working (I'm assuming that is why you are outputting the query)? During debugging, I often echo the query and paste it into PHPMyAdmin in order to better understand what is going wrong.




Theme © iAndrew 2016 - Forum software by © MyBB