我的 SQL 技能有点有限,但我可以弄清楚如何长期查询事物。有没有更好的方法可以在一个操作中执行下面的 SQL 语句,而不是将其分成三个?
$db = JFactory::getDbo();
$query = "SELECT email FROM xx_opencart_customer WHERE customer_id = '".$this->session->data['customer_id']."'";
$db->setQuery($query);
$results = $db->loadObjectList();
foreach ($results as $t) {;
}
$db = JFactory::getDbo();
$query = "SELECT id FROM xx_users WHERE email = '".$t->email."'";
$db->setQuery($query);
$results = $db->loadObjectList();
foreach ($results as $t) {;
}
$db = JFactory::getDbo();
$query = "SELECT group_id FROM xx_user_usergroup_map WHERE user_id = '".$t->id."'";
$db->setQuery($query);
$results = $db->loadObjectList();
foreach ($results as $t) {;
}
最终结果我能够告诉 $t->group_id 等于什么。