Advertisement
vanchelo

MODX Revo 2.2.5, PDO

Oct 13th, 2012
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2. $time_start = microtime(true);
  3. $c = $modx->newQuery('modResource');
  4. $c->select(array('id','pagetitle','longtitle','content'));
  5. $c->where(array('id:>=' => 6));
  6.  
  7. $c->limit(1000);
  8.  
  9. if($c->prepare() && $c->stmt->execute()) {
  10.     $collection = $c->stmt->fetchAll(PDO::FETCH_ASSOC);
  11. }
  12.  
  13. $output = array();
  14. $i=0;
  15. foreach ($collection as $res) {
  16.     $output[] = $modx->getChunk('tpl',$res);
  17.     $i++;
  18. }
  19.  
  20. $output = implode("\n",$output);
  21.  
  22. echo $output;
  23.  
  24. $time_end = microtime(true);
  25. $time = $time_end - $time_start;
  26. echo 'Ресурсов: ' . $i . '<br />';
  27. echo 'Памяти скушано: ' . round(memory_get_peak_usage(true)/(1024*1024),2) . 'Мб<br />';
  28. echo 'Время работы сниппета ' . $time . ' сек <br />';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement