Solo puede tener una consulta a la vez en PHP.
$query1 = "SELECT count(*) FROM agents INTO @AgentCount"
$query2="
SELECT user_agent_parsed, user_agent_original, COUNT( user_agent_parsed ) AS thecount,
COUNT( * ) / ( @AgentCount) AS percentage
FROM agents
GROUP BY user_agent_parsed
ORDER BY thecount DESC LIMIT 50";
ACTUALIZAR
Tengo un DAL que contiene todas mis consultas. Una función típica en mi DAL se ve así:
// These functions are reusable
public function getAllRows($table)
{
$sql =" SELECT * FROM $table";
$this->query($sql);
return $this->query_result;
}
Luego, en mi BLL (Business Layer) tengo lo siguiente:
public function getUserAgents()
{
$result = parent::getAllRows();
$row = mysql_fetch_array($result);
return $row[0]; // Retrieves the first row
// Then you take this value and to a second request. Then return the answer / rows.
}