Advertisement
vanchelo

Test PDO vs xPDO

Oct 11th, 2012
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. $time_start = microtime(true);
  3. $c = $modx->newQuery('modResource');
  4. $c->select(array('id','pagetitle'));
  5. $c->where(array('id:<' => 1000));
  6.  
  7. for ($i = 1000; $i >= 0; $i--) {
  8.     if($c->prepare() && $c->stmt->execute()) {
  9.         $collection = $c->stmt->fetchAll(PDO::FETCH_ASSOC);
  10.     }
  11.     $x = array();
  12.     foreach ($collection as $key => $value) {
  13.         $x[] = $value;
  14.     }
  15. }
  16. $time_end = microtime(true);
  17. $time = $time_end - $time_start;
  18. echo $time;
  19.  
  20. echo '<br />';
  21.  
  22. $time_start = microtime(true);
  23.  
  24. for ($i = 1000; $i >= 0; $i--) {
  25.     $collection = $modx->getCollection('modResource',$c);
  26.  
  27.     foreach ($collection as $key => $value) {
  28.         $value->toArray();
  29.     }
  30. }
  31. $time_end = microtime(true);
  32. $time = $time_end - $time_start;
  33. echo $time;
  34. die('<br />Закончили');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement