Многократный запрос Joomla на одной странице, возвращающий только последний запрос - PullRequest
0 голосов
/ 24 октября 2018

Я пишу страницу php для использования в Joomla, и мне нужно иметь три разных запроса: два запроса к одной и той же таблице с различным предложением WHERE и третий запрос ко второй таблице.Вот мой код:

<?php 
// Cnnect to response database and get the user's data that matches the logged in user
$query_user->select($db_user->quoteName(array('user_ID', 'parent_id', 'mbr_status', 'payment_status')))
               ->from($db_user->quoteName('mb_response'))
               ->where($db_user->quoteName('user_ID') . ' LIKE ' . $db_user->quote($joomla_user_id));


// Cnnect to response database and get the other's data that are related to the logged in user
$query_other->select($db_other->quoteName(array('user_ID', 'parent_id', 'mbr_status', 'payment_status')))
            ->from($db_other->quoteName('mb_response'))
            ->where($db_other->quoteName('user_ID') . ' LIKE ' . $db_other->quote($joomla_user_id));

// Connect to profile database and user's information that matches the logged in user
$query_profile->select($db_profile->quoteName(array('user_ID', 'address', 'phone')))
              ->from($db_profile->quoteName('mb_user_profile'))
              ->where($db_profile->quoteName('user_ID') . ' LIKE ' . $db_profile->quote($joomla_user_id));


// Reset the query using our newly populated query object.
$db_user->setQuery($query_user);
$db_other->setQuery($query_other);
$db_profile->setQuery($query_profile);

// Load the results as a list of stdClass objects<br>
$row_user = $db_user->loadAssoc();
$row_other = $db_other->loadAssoc();
$row_profile = $db_profile->loadAssoc();

// Extract all keys and values for the row and add a PREFIX based on the query. All prefixes ends with _ e.g $user_user_ID 
extract($row_user, EXTR_PREFIX_ALL, "user");
extract($row_other, EXTR_PREFIX_ALL, "other");
extract($row_profile, EXTR_PREFIX_ALL, "profile");

print_r($row_user);
print_r($row_other);
print_r($row_profile);
?>

К сожалению, когда я проверяю результат с print_r для каждого $ row_, они все одинаковы и являются результатом последнего запроса.

Я не уверен, как решить эту проблему.Благодарю.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...