我的查询如下:
$user = JFactory::getUser();
$uid = $user->id;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT a.id, a.menu_item_id, a.req_form FROM `team_form_lists` AS a LEFT JOIN #__comprofiler AS f ON f.cb_teamid = a.team_number WHERE f.user_id = $uid";
$db->setQuery($query);
$forms = $db->loadObjectList('id');
return $forms;
它返回:
Array (
[3] => stdClass Object ( [id] => 3 [menu_item_id] => 1378 [req_form] => 334 Basic Information Form )
[4] => stdClass Object ( [id] => 4 [menu_item_id] => 1379 [req_form] => 334 Extra Curricular Activity Consent and Release )
[5] => stdClass Object ( [id] => 5 [menu_item_id] => 1377 [req_form] => 334 Florida FHSAA Concussion )
[7] => stdClass Object ( [id] => 7 [menu_item_id] => 1380 [req_form] => 334 Emergency Treatment Authorization and Health Emergency Information )
[8] => stdClass Object ( [id] => 8 [menu_item_id] => 1381 [req_form] => 334 Random Drug and Alcohol Testing )
)
这正是我需要生成动态“菜单”以允许用户使用链接导航到相应的表单。
问题是,我想针对另一个db表“测试”表单以查看哪些表格已经填写完毕。 我尝试过这样的查询:
foreach ($forms as $form){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query = "SELECT COUNT( `id` ) FROM `#__facileforms_records` WHERE `title` = '$form->req_form' AND `user_id` = $uid ";
$db->setQuery($query);
$state = $db->loadResult();
return $state;
}
问题是,第二个查询返回相同的数组。我知道这归结为我的无知,只是寻找正确方向的推动,谢谢。
答案 0 :(得分:0)
事实上它正在返回一个数组就是放弃了。第一个查询仍然有$查询。你需要做出$ query2或者做$ query-> clear();.那么你将从干净的石板开始。