Quote:
Originally Posted by Kyttias
top 10 most active users last week = ???
top 10 most active users last month = ???
most owned pet = ???
|
Well in these cases you will need to make use of some complex MYSQL syntax. One hint I can give to you is that Mysidia's Database class inherits from PDO, so whatever syntax works with PDO will work here too. You can just execute a query using SQL syntax like this, for complex features not provided in the current database class yet. For instance, to fetch the user with most money, you can just run this query below:
PHP Code:
$mysidia->db->query("SELECT MAX(money) FROM {$prefix}users");
In your case, this below query will do:
PHP Code:
$mysidia->db->query("SELECT type, COUNT(type) AS favpet FROM {$prefix}owned_adoptables GROUP BY type LIMIT 1");
Note you will need to manually add the $prefix to the database table name, which is cumbersome and error-prone. It is one of the primary reasons that Mysidia uses query builders nowadays(so you are free of the concern of prefixing database tables, the script does it for you behind the scene). But of course, the query builder has limited functionality so far, so to execute complex SQL queries you have to fall back to the plain old SQL approach.