S
S
sergmit2019-04-29 12:01:32
Joomla
sergmit, 2019-04-29 12:01:32

How to get query from database in plugin?

In the onAfterRoute method of the plugin, I make a request to the database, an empty response comes, I copied the request to phpmyadmin, the result is

$query = $db->getQuery(true);
$query->select('refs.*');
$query->select('users.username');
$query->from($db->qn('#__pharaoh_refs', 'refs'));
$query->leftJoin($db->qn('#__users', 'users') . "ON " . $db->qn('refs.uid') . " = " . $db->qn('users.id'));
$query->where($db->qn('refs.code') . "=" . $db->q($code));
$db->setQuery($query); 
$res = $db->loadAssoc();
echo "$query<br>"; //в phpmyadmin есть результат
echo "<pre>";
print_r($res); // Пустой массив
echo "</pre>";

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question