I am trying to query a table in my DB and am not able to get any results back. Here is the code I am using:
function get_agent_info($agent) {
$query = db_query("SELECT * FROM tls_connect_stage_timer WHERE '".$agent."' IN ('start_processing_agent' || 'end_processing_agent')");
$rows = array();
foreach ($query as $result) {
$rows[] = array(
$result -> applicant_id,
$result -> stage,
$result -> event_start,
$result -> event_end,
$result -> start_processing_agent,
$result -> end_processing_agent,
$result -> start_request_ip,
$result -> end_request_ip,
$result -> gwf,
);
}
print_r($rows);
}
I have already used a method like this to get info:
$results = db_query("SELECT * FROM tls_active_applicants WHERE `".$searchParams."`='".$input."'");
$rows = array();
foreach($results as $result){
$rows[] = array(
$result -> first_name,
$result -> last_name,
$result -> gwf,
$result -> visa_type,
$result -> current_stage,
);
}
The second one works fine, where with the first one, if I print_r($rows) it returns an empty array. Why is the foreach loop starting in the first example but not the second? I've tested the query, and it works fine. Also any links that could help me understand how the foreach loop is working would be greatly appreciated. I assumed that since it's saying $query as $result, I would be able to pull a single value saying something like $query->stage but that didn't work. I'm assuming because there are several entries I would need to do something like $query[0]->stage but I don't really know how that works when it comes to calling properties..