Last active
June 29, 2018 08:44
-
-
Save vgrish/3a01ea308a6f7c440d08272e56195167 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$c = $modx->newQuery('modUser'); | |
$c->InnerJoin('modUserProfile', 'Profile'); | |
$c->InnerJoin('msOrder', 'msOrder', 'modUser.id = msOrder.user_id'); | |
$c->InnerJoin('msOrderAddress', 'msOrderAddress','msOrder.address = msOrderAddress.id'); | |
$c->where(array( | |
'modUser.active' => 1, | |
)); | |
$c->groupby('modUser.id'); | |
$c->select($modx->getSelectColumns('modUser', 'modUser', '', array('id'))); | |
$c->select($modx->getSelectColumns('modUserProfile', 'Profile', '', array('fullname'))); | |
$c->select($modx->getSelectColumns('modUserProfile', 'msOrderAddress', '', array('city'))); | |
$fp = fopen(MODX_BASE_PATH.'users.csv', 'w'); | |
fputcsv($fp, array('id', 'name', 'city')); | |
if ($c->prepare() && $c->stmt->execute()) { | |
while($row = $c->stmt->fetch(PDO::FETCH_ASSOC)) { | |
fputcsv($fp, $row); | |
} | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment