UpdatesController.php 806 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class UpdatesController extends Zend_Controller_Action
  3. {
  4. public function indexAction()
  5. {
  6. $queries = (int) $this->getParam('queries', 1);
  7. $queries = max(1, $queries);
  8. $queries = min(500, $queries);
  9. $table = new Model_World();
  10. $worlds = array();
  11. for ($i = 0; $i < $queries; $i += 1) {
  12. $id = mt_rand(1, 10000);
  13. $random_number = mt_rand(1, 10000);
  14. $world = $table->fetchRow(array('id = ?' => $id))->toArray();
  15. $world['randomNumber'] = $random_number;
  16. $where = $table->getAdapter()->quoteInto('id = ?', $id);
  17. $table->update(array('randomNumber' => $random_number), $where);
  18. $worlds[] = $world;
  19. }
  20. $this->_helper->json->sendJson($worlds);
  21. }
  22. }