• We value your experience with Plesk during 2024
    Plesk strives to perform even better in 2025. To help us improve further, please answer a few questions about your experience with Plesk Obsidian 2024.
    Please take this short survey:

    https://pt-research.typeform.com/to/AmZvSXkx
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Resolved Plesk SQL query to find domains and PHP versions

Laurence@

Regular Pleskian
In 2018 it's my mission to upgrade 10,000 websites to PHP 7. Can someone give me the SQL query to:

1) Find the overall number of websites on a particular PHP version.
2) List all said domains on a particular PHP version.

Cheers.
 
Try to use as basis something like:

mysql> select dom.name, h.php_handler_id from domains dom LEFT JOIN hosting h ON (dom.id=h.dom_id) order by h.php_handler_id;

you can easily modify it according your needs.
 
Hi, Igor, Thank you for this.
How would I also get the Version of WordPress used by those domains?
I found this to get the WP version:
select dom.name, dp.val, h.php_handler_id from domains dom LEFT JOIN dom_param dp ON (dom.id=dp.dom_id) where dp.param="wapp" or dp.param="wapp-version"
How can I combine the two queries?
 
* You need to add both JOINs to the query to select from all three tables.
* When JOINing multiple tables, add conditions that only apply to one table to the JOIN to get a faster result.
* I replaced the 'hosting' join to an INNER JOIN so that sites that used to have a wordpress installation but changed to 'nohosting' won't be shown. This could be the case if they were migrated to another provider but kept the DNS on the current plesk server. Replace with LEFT JOIN if this is not desired.
* The 'LEFT JOIN' will list sites where wordpress is not present (dp.val will be NULL) there. Replace the 'LEFT JOIN' on dom_param by INNER JOIN if you only want to see the wordpress sites.
* The ORDER BY will list the oldest php versions first.
* When comparing a SQL column to a fixed value, use single quotes.

SQL:
SELECT dom.name, dp.val, h.php_handler_id
    FROM psa.domains dom   
    INNER JOIN psa.hosting h ON (dom.id=h.dom_id)
    LEFT JOIN psa.dom_param dp ON (dom.id=dp.dom_id) AND (dp.param='wapp' or dp.param='wapp-version')
    ORDER BY h.php_handler_id ASC, dp.val ASC;
 
Back
Top