Last active
March 24, 2016 11:35
-
-
Save justenj/e1a38f9a0cb5908379f5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
$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