krot

MODX new Package

Sep 22nd, 2017
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <? $modx->addPackage('MapProduct', $modx->getOption('core_path').'components/MapProduct/model/','modx_');
  2. or add var(системные переменные) [{"collections":{"path":"[[++core_path]]components/collections/model/"}},{"MapProduct":{"path":"[[++core_path]]components/MapProduct/model/"}}]
  3.  
  4. $item = $modx->newObject('MapProduct');
  5. print_r($item->toArray());
  6.  
  7.  
  8.  
  9.  
  10. <?php
  11. $modx->addPackage('MapProduct', $modx->getOption('core_path').'components/MapProduct/model/','modx_');
  12.  
  13. $pdo = $modx->getService('pdoTools');
  14. $q = $modx->newQuery('MapProduct');
  15. $q->select( array("id","art") );
  16. $q->limit(2000);
  17. $s = $q->prepare();
  18. $s->execute();
  19. while($row = $s->fetch(PDO::FETCH_ASSOC)) {
  20.     print $row['art'].PHP_EOL;
  21. }
  22. print '<pre>'; print_r($pdo->getTime()); print '</pre>';
  23.  
  24. $pdo = $modx->getService('pdoTools');
  25. $q = $modx->prepare("SELECT * FROM modx_map_product LIMIT 2000");
  26. $q->execute();
  27. while($row = $q->fetch(PDO::FETCH_ASSOC)) {
  28.     print $row['art'].PHP_EOL;
  29. }
  30. print '<pre>'; print_r($pdo->getTime()); print '</pre>';
  31. ----------------------
  32. <?php
  33. $modx->addPackage('MapProduct', $modx->getOption('core_path').'components/MapProduct/model/','modx_');
  34. $q = $modx->newQuery('MapProduct');
  35. $q->select(array("id","art"));
  36. $q->limit(2000);
  37. $query = $q->prepare();
  38. $query->execute();
  39. while($row = $query->fetch(PDO::FETCH_ASSOC)) {
  40.     print $row['art'] . "\n";
  41. }
RAW Paste Data