• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • 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.

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