After reading symfony 1.4 doc, i manage to reduce admin generator query to a lower number. If u notice, there is very high number of query for admin generator module in table that has many relationship. Luckily, Symfony 1.4 has built a way for us reduce the query easily.
To reduce the admin generator query in symfony 1.4, follow the steps below:-
Advertisements
- Assuming you are trying to select staff details and left join staff_profiles and jobs table for full details. Now, create the function below in your action.class.php file:-
public function buildQuery() { return parent::buildQuery() ->leftJoin('r.StaffProfile as p ON r.staff_id = p.id') ->leftJoin('r.Job as j ON r.staff_id = j.id'); }
- Now you refresh the page and you should see the number of query has been reduced.
Related posts:
Speed Up and Save Your Website Bandwidth with GZip Compression
Symfony 1.4: How to sort foreign key record?
How to remove newline character in PHP
Composer: PHP Fatal error: Allowed memory size of ... exhausted...
How to extract img tag attributes using PHP?
PHP Fatal error: Class ‘DOMDocument’ not found in …
Virtue Theme: How to enable slider in shop page?
Symfony 1.4 - Customize Admin Generator listing to show data from foreign tables
Share this with your friends:-
actually the way above is a lazy shortcut way :p
table_method is a good way to customize your own query
thanks Fizyk for pointing out 🙂
Have you checked the table_method option from generator.yml?
http://www.symfony-project.org/reference/1_4/en/06-Admin-Generator#chapter_06_sub_table_method