Skip to content

Instantly share code, notes, and snippets.

@opengeek
Created August 21, 2012 20:24
Show Gist options
  • Save opengeek/3419076 to your computer and use it in GitHub Desktop.
Save opengeek/3419076 to your computer and use it in GitHub Desktop.
<?php
$path = MODX_CORE_PATH . 'components/getCourses/';
$result = $modx->addPackage('getCourses',$path . 'model/');
if ($result) {
$c = $modx->newQuery('Courses201213Combined');
$whereArray = array();
// Get query string parameters
$catalog_nbr = filter_var($_GET['catalog_nbr'], FILTER_SANITIZE_STRING);
if (!empty($catalog_nbr)) { $whereArray['catalog_nbr:='] = $catalog_nbr; }
if (!empty($whereArray)) {
$c->where($whereArray);
}
$rows = $modx->getIterator('Courses201213Combined', $c);
if ($rows) {
$newArray = array();
foreach ($rows as $idx => $row) {
$newArray[] = $row->toArray('',true);
$newArray['zerofill_column'] = $row->get('zerofill_column', '%010s');
}
$json = $modx->toJSON($newArray);
return $json;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment