Anda hanya dapat memiliki satu kueri dalam satu waktu di 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";
PERBARUI
Saya memiliki DAL yang berisi semua pertanyaan saya. Fungsi khas di DAL saya terlihat seperti ini:
// These functions are reusable
public function getAllRows($table)
{
$sql =" SELECT * FROM $table";
$this->query($sql);
return $this->query_result;
}
Kemudian di BLL (Lapisan Bisnis) saya, saya memiliki yang berikut:
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.
}