File indexing completed on 2024-04-28 05:55:23

0001 <?php
0002 
0003 class PostsModel extends EModel
0004 {
0005         public function __construct()
0006         {
0007                 parent::__construct("posts");
0008         }
0009         
0010         public function getNear($x, $y, $z, $factor)
0011         {
0012       $xu = $x+$factor;
0013       $xl = $x-$factor;
0014       
0015       $yu = $y+$factor;
0016       $yl = $y-$factor;
0017       
0018       $zu = $z+$factor;
0019       $zl = $z-$factor;
0020       
0021       $data = $this->find("*", "where x > $xl and x < $xu and y > $yl and y < $yu and z > $zl and z < $zu ORDER BY up DESC, id DESC");
0022       
0023       return $data;
0024         }
0025         
0026         public function voteup($id)
0027         {
0028       $q = "UPDATE posts SET up = up+1 WHERE id = ".$id." LIMIT 1";
0029       $r = EDatabase::q($q);
0030     }
0031         
0032         public function votedown($id)
0033         {
0034       $q = "UPDATE posts SET down = down+1 WHERE id = ".$id." LIMIT 1";
0035       $r = EDatabase::q($q);
0036     }
0037         
0038         public function add()
0039         {
0040       $this->insert(array("x", "y", "z", "body", "owner"));
0041         }
0042         
0043         public function clearAll()
0044         {
0045       $this->delete();
0046     }
0047         
0048 }
0049 
0050 ?>