Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. class db {
  3. private $user = "7nowakm" ;
  4. private $pass = "pass7nowakm";
  5. private $host = "pascal.fis.agh.edu.pl";
  6. private $base = "7nowakm";
  7. private $coll = "??????";
  8. private $conn;
  9. private $dbase;
  10. private $collection;
  11.  
  12. function __construct() {
  13. $this->conn = new MongoDB\Client("mongodb://{$this->user}:{$this->pass}@{$this->host}/{$this->base}");
  14. $this->collection = $this->conn->{$this->base}->{$this->coll};
  15. }
  16.  
  17. function select() {
  18. $cursor = $this->collection->find();
  19. $table = iterator_to_array($cursor);
  20. return $table ;
  21. }
  22.  
  23. function insert($user) {
  24. $ret = $this->collection->insertOne($user) ;
  25. return $ret;
  26. }
  27.  
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement