News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

$smcFunc['db_query'](..) nested queries

Started by eKKiM, September 01, 2016, 01:53:55 PM

Previous topic - Next topic

eKKiM

Hi is there any way to executed nested queries using $smcFunc['db_query'](..)

I have a special case where i want to build a ranking system.

I have kind of the following structure:

+------------------------------------------------------+
|             smf_challenge_completions                |
+--------------+-----------+--------+------------------+
| id_challenge | id_member | points | submit_timestamp |
+--------------+-----------+--------+------------------+
| ....


SELECT id_member, SUM(points) AS total_points, MAX(submit_timestamp), @rownum := @rownum + 1 AS rank
FROM smf_challenge_completions, (SELECT @rownum := 0) r
ORDER BY total_points DESC, submit_timestamp DESC
GROUP BY id_member, rank

and

SELECT rank FROM
(
SELECT id_member, SUM(points) AS total_points, MAX(submit_timestamp), @rownum := @rownum + 1 AS rank
FROM smf_challenge_completions, (SELECT @rownum := 0) r
ORDER BY total_points DESC, submit_timestamp DESC
GROUP BY id_member, rank
)  AS t
WHERE id_member = ?


Always getting Hacking attempt... because of db_query security..

vbgamer45

Set before you run the query
$modSettings['securityDisable'] = 1;

And after your run it set it to
$modSettings['securityDisable'] = 0;
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

eKKiM

It seems like


$modSettings['disableQueryCheck'] = 1;


does the trick

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Matthew K.


Advertisement: