Skip to content

Commit

Permalink
fixes for sql
Browse files Browse the repository at this point in the history
stupid mistakes :(
didn't test it before I upload it
  • Loading branch information
Wies committed Oct 13, 2013
1 parent 4576b57 commit 1bcfd65
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions PlotPe.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function command($cmd, $args, $issuer){
break;
}
$plot = $plot[0];
if($plot['owner'] != ''){
if($plot['owner'] != NULL){
$output = "This plot is already claimed by somebody";
break;
}
Expand All @@ -222,12 +222,14 @@ public function command($cmd, $args, $issuer){
break;

case 'auto':
$plot = $this->getPlotByOwner('');
if($plot === false){
$query = "SELECT * FROM plots WHERE owner IS NULL";
$result = $this->database->query($query);
if($result instanceof SQLite3Result){
$plot = $result->fetchArray(SQLITE3_ASSOC);
}else{
$output = 'Their are no available plots anymore';
break;
}
$plot = $plot[0];
$id = $plot['id'];
$sql = "UPDATE plots SET owner = $iusername WHERE id = $id;";
$this->database->exec($sql);
Expand Down Expand Up @@ -306,6 +308,9 @@ public function command($cmd, $args, $issuer){
$output = $player.' is no helper of this plot';
}
break;
default:
return false;
break;
}
return $output;
}
Expand All @@ -314,7 +319,7 @@ public function tpToPlot($plot, $player){
$middle = $this->config['PlotSize'] / 2;
$x = $plot['x1'] + $middle;
$z = $plot['z1'] + $middle;
$level = $plot['level'];
$level = $this->api->level->get($plot['level']);
$player->teleport(new Position($x, 27, $z, $level));
}

Expand Down Expand Up @@ -358,7 +363,7 @@ public function getPlotByOwner($username){
$query = "SELECT * FROM plots WHERE owner = $username";
$result = $this->database->query($query);
if($result instanceof SQLite3Result){
while ($entry = $result->fetchArray()){
while ($entry = $result->fetchArray(SQLITE3_ASSOC)){
$finalresult[] = $entry;
}
}else{
Expand Down Expand Up @@ -388,6 +393,8 @@ public function block($data){
return false;
}

public function __destruct(){}
public function __destruct(){
$this->database->close();
}

}

0 comments on commit 1bcfd65

Please sign in to comment.