$post = $this->db->fetch_array_all( "SELECT * FROM `post` ORDER BY `id` DESC LIMIT 0, 10;" ); $type_1 = $this->db->fetch_array_all( "SELECT COUNT(*) FROM `smile` WHERE `post_id` = ".$this->db->quote_($this->id)." AND `enabled` = 1 AND `type_smile` = 1;"); $type_2 = $this->db->fetch_array_all( "SELECT COUNT(*) FROM `smile` WHERE `post_id` = ".$this->db->quote_($this->id)." AND `enabled` = 1 AND `type_smile` = 2;"); $type_3 = $this->db->fetch_array_all( "SELECT COUNT(*) FROM `smile` WHERE `post_id` = ".$this->db->quote_($this->id)." AND `enabled` = 1 AND `type_smile` = 3;"); Is it possible not to send 3 requests, but to execute 1 and no matter what the performance
Each post has 3 smiles:
- :) it's good
- -) this is normal
- :( This is bad
All vote in the end then on the main page you will need to display the title of the post and 3 smiles with the number of votes for each smile, and the post is also a smile and it will need to be taken into account
As a result, we consider
Suppose on the page you need to display the last 10 topics, for each topic you need to display smiles and you get 30 requests !!!
How can you simplify?
Here it will look like