World.php 755 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace Vanilla\DataMapper;
  3. use Pimf\DataMapper\Base;
  4. class World extends Base
  5. {
  6. /**
  7. * @param integer $id
  8. *
  9. * @return array
  10. */
  11. public function find($id)
  12. {
  13. $sth = $this->pdo->prepare('SELECT * FROM World WHERE id = :id');
  14. $sth->bindValue(':id', $id, \PDO::PARAM_INT);
  15. $sth->execute();
  16. return (array) $sth->fetch(\PDO::FETCH_ASSOC);
  17. }
  18. /**
  19. * @param array $world
  20. *
  21. * @return bool
  22. */
  23. public function update(array $world)
  24. {
  25. $sth = $this->pdo->prepare('UPDATE World SET randomNumber = :randomNumber WHERE id = :id');
  26. $sth->bindValue(':randomNumber', $world['randomNumber'], \PDO::PARAM_INT);
  27. $sth->bindValue(':id', $world['id'], \PDO::PARAM_INT);
  28. return $sth->execute();
  29. }
  30. }