View Single Post
  #2  
Old 01-18-2015, 11:26 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 342,226
Hall of Famer is on a distinguished road
Default

Quote:
Originally Posted by Kyttias View Post

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.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote