Who doesn’t love a totally strange message from a stranger about something completely random? ( and Export customers scripts)

r4dicalghost

New member
XNullUser
Joined
Feb 28, 2022
Messages
1
Reaction score
0
Points
1
NullCash
9
Nice to meet u.
In your opinion, how many cats are too many cats?

I'm ghost and I'm.. wait for it.. **FRENCH**.. Anyway..
I have been a web developer for 20 years.
As a result, my code is old and often sucks.

Below some code that can be used to export French users (id_country = 8) who have already placed orders :

function getDataInDatabase() {
$query = "SELECT result.`id_customer` AS `ID`, result.`email` AS `EMAIL`, result.`id_gender` AS `GENRE`, result.`firstname` AS `PRENOM`,
result.`lastname` AS `NOM`, result.`birthday` AS `ANNIV`, result.`optin` AS `OPTIN`, result.`newsletter` AS `NEWSLETTER`, ad.`id_country` AS `PAYS`, ad.`phone` AS `TEL`,
result.`TotCommandes` AS `TOTALPAYE`, result.`NbCommandes` AS `NBCOMMANDES` FROM ( SELECT c.`id_customer`, c.`email`, c.`id_gender`, c.`firstname`, c.`lastname`, c.`birthday`, c.`optin`, c.`newsletter`, SUM(o.`total_paid`) AS TotCommandes, count(o.`id_order`) AS `NbCommandes`
FROM `"._DB_PREFIX_."customer` c LEFT JOIN `"._DB_PREFIX_."orders` o on c.`id_customer` = o.`id_customer` WHERE o.`valid` = 1 group by o.`id_customer` ) AS result
INNER JOIN `"._DB_PREFIX_."address` ad ON result.`id_customer` = ad.`id_customer`
WHERE ad.`id_country` = 8
GROUP BY result.`id_customer`";
.... don't forget to use and close this shit at the end.

I have other shitty codes to export users who have never placed orders...

Enjoy and have a good day.. obviously like if you like it, or if you think it's shit ;)
 
Top