Query is not working

For Joomla! 3.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, General Support Moderators

Forum rules
Locked
RemiAdem45
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sat Aug 18, 2018 10:11 am

Query is not working

Post by RemiAdem45 » Sun Apr 02, 2023 9:29 am

Hello

Here is my request:

Code: Select all

$query = $bdd->getQuery(true);
$cond="a.clef= PASSWORD('".$_POST['form']['identifiant']."')";
$query
    ->select(array('a.ref', 'b.Nom', 'b.Prenom','c.Email'))
    ->from($bdd->quoteName('#__XXXIDlecon', 'a'))
    ->join('INNER', $bdd->quoteName('#__XXXmembres', 'b') . ' ON ' . $bdd->quoteName('a.ref') . ' = ' . bdd->quoteName('b.Ref'))
    ->join('INNER', $bdd->quoteName('#__XXXcontacts', 'c') . ' ON ' . $bdd->quoteName('a.ref') . ' = ' . $bdd->quoteName('c.Membre'))
    ->where($cond);
$bdd->setQuery($query);
$result = $bdd->loadAssoc();
And the result is an empty array

But if I go to my data base with phpmyadmin and I run this request I have a result
here is the equivalent of the request in sql

Code: Select all

SELECT a.ref, b.Nom,b.Prenom,c.Email from yyy000_XXXIDlecon as a
INNER join yyy000_XXXmembres AS b ON a.ref = b.Ref
INNER join yyy000_XXXcontacts as c ON a.ref = c.Membre
WHERE a.clef= PASSWORD('mdp');
Is there any way to see what is exactly in $query too see why this request is not working
Last edited by Per Yngve Berg on Sun Apr 02, 2023 9:51 am, edited 1 time in total.
Reason: Moved from Language to Coding Forum.

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24986
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Query is not working

Post by pe7er » Sun Apr 02, 2023 10:37 am

RemiAdem45 wrote:
Sun Apr 02, 2023 9:29 am
Is there any way to see what is exactly in $query too see why this request is not working
Yes, add the following line:

Code: Select all

echo $query->dump();
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com

RemiAdem45
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sat Aug 18, 2018 10:11 am

Re: Query is not working

Post by RemiAdem45 » Sun Apr 02, 2023 10:49 am

I manage to see what is in my query with your function and the query seems to be correct.
Just to be sure I tried an other one without jointure

Code: Select all

$query = $bdd->getQuery(true);
$query
    ->select(array('b.Nom', 'b.Prenom'))
    ->from($bdd->quoteName('#__XXXmembres', 'b')
    ->where($cond);
$bdd->setQuery($query);
$result = $bdd->loadAssoc();
the result is still empty but if I use $bdd->loadObject() instead of $bdd->loadAssoc();
I have the result


Locked

Return to “Joomla! 3.x Coding”