Skip to content

Instantly share code, notes, and snippets.

@justenj
Last active March 24, 2016 11:35
Show Gist options
  • Save justenj/e1a38f9a0cb5908379f5 to your computer and use it in GitHub Desktop.
Save justenj/e1a38f9a0cb5908379f5 to your computer and use it in GitHub Desktop.
<?php
$class = 'modResource';
$pdo = $modx->getService('pdoFetch');
$pdo->addTime('pdoFetch загружен');
$options = array(
'cacheTime' => '11',
);
if (!$output = $pdo->getCache($options)) {
$pdo->addTime('Кэш не найден, генерируем данные');
$pdo->setConfig(array(
'class' => $class,
'select' => 'id, properties',
'limit' => 0,
'parents' => 0,
'return' => 'data'
));
$data = $pdo->run();
$output = array();
foreach ($data as $row) {
if (isset($row['properties']['tickets']['rating']) && $row['properties']['tickets']['rating'] > 0) {
$output[] = $row['id'];
}
}
$output = implode(',', $output);
$pdo->setCache($output, $options);
$pdo->addTime('Данные сохранены в кэш');
} else {
$pdo->addTime('Данные загружены из кэша');
}
$pdo->addTime('Данные получены');
print $pdo->getTime();
print $output;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment