Skip to content

Instantly share code, notes, and snippets.

@yashodhank
Forked from agarzon/plesk.sql
Created January 9, 2019 11:30
Show Gist options
  • Save yashodhank/516181866f9984482dcada91d4682622 to your computer and use it in GitHub Desktop.
Save yashodhank/516181866f9984482dcada91d4682622 to your computer and use it in GitHub Desktop.
Generate report with all domains by client and plan (plesk)
SELECT domains.name as domain, Templates.name as plan, domains.status, clients.type, clients.login, clients.pname, clients.email, clients.external_id, Subscriptions.locked, Subscriptions.synchronized, Subscriptions.custom
FROM domains
LEFT JOIN clients ON domains.cl_id = clients.id
LEFT JOIN Subscriptions ON domains.id = Subscriptions.object_id AND Subscriptions.object_type = 'domain'
LEFT JOIN PlansSubscriptions ON Subscriptions.id = PlansSubscriptions.subscription_id
LEFT JOIN Templates ON PlansSubscriptions.plan_id = Templates.id
WHERE clients.type = 'client'
AND clients.parent_id = '1'
AND domains.parentDomainId = '0'
INTO OUTFILE '/tmp/domains-client.csv';
# Reseller
SELECT Templates.name as plan, clients.status, clients.type, clients.login, clients.pname, clients.email, clients.external_id, Subscriptions.locked, Subscriptions.synchronized, Subscriptions.custom
FROM `clients`
LEFT JOIN Subscriptions ON clients.id = Subscriptions.object_id AND Subscriptions.object_type = 'client'
LEFT JOIN PlansSubscriptions ON Subscriptions.id = PlansSubscriptions.subscription_id
LEFT JOIN Templates ON PlansSubscriptions.plan_id = Templates.id
WHERE clients.type = 'reseller'
INTO OUTFILE '/tmp/reseller-client.csv';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment