Guest User

Untitled

a guest
Jun 12th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. $path = MODX_CORE_PATH . 'components/quotes/';
  3. $result = $modx->addPackage('quotes',$path . 'model/quotes/','modx_');
  4. $output = '';
  5.  
  6. if (! $result) {
  7.   return 'failed to add package';
  8. } else {
  9.   $output .= '<p>added Package</p>';
  10. }
  11.  
  12. $database_server = '**';
  13. $database_type = '**';
  14. $dbase = '**';
  15. $database_user = '**';
  16. $database_password = '**';
  17. $table_prefix = '**';
  18.  
  19. $xpdo = new xPDO("mysql:host=$database_server;dbname=$dbase",
  20. $database_user,$database_password,$table_prefix);
  21.  
  22.  
  23. $output .= ($xpdo->connect()) ? '<p>Connected</p>' : '<p>Not Connected</p>';
  24.  
  25. /*test for adding new object, commented out
  26. $newObj = $xpdo->newObject('Quotation');
  27. $newObj->fromArray(array('quote' => 'sdfjkhjkashf dkashfjkhd skf'));
  28. $newObj->save();
  29. */
  30.  
  31. $quotes = $xpdo->getCollection('Quotation');
  32.  
  33. $output .= '<p>Total: '. count($quotes) . '</p>';
  34.  
  35. foreach($quotes as $quote) {
  36.    $output .= '<br />Quote: ' . $quote->get('quote');
  37. }
  38.  
  39.  
  40. return $output;
Add Comment
Please, Sign In to add comment