This commit is contained in:
Shoghi Cervantes 2013-06-10 17:10:40 +02:00
parent 33733cd608
commit 4284211bd1

View File

@ -143,7 +143,7 @@ class PocketMinecraftServer{
public function query($sql, $fetch = false){ public function query($sql, $fetch = false){
$result = $this->database->query($sql) or console("[ERROR] [SQL Error] ".$this->database->lastErrorMsg().". Query: ".$sql, true, true, 0); $result = $this->database->query($sql) or console("[ERROR] [SQL Error] ".$this->database->lastErrorMsg().". Query: ".$sql, true, true, 0);
if($fetch === true and ($result !== false and $result !== true)){ if($fetch === true and ($result instanceof SQLite3Result)){
$result = $result->fetchArray(SQLITE3_ASSOC); $result = $result->fetchArray(SQLITE3_ASSOC);
} }
return $result; return $result;
@ -228,7 +228,7 @@ class PocketMinecraftServer{
$this->preparedSQL->selectHandlers->bindValue(":name", $event, SQLITE3_TEXT); $this->preparedSQL->selectHandlers->bindValue(":name", $event, SQLITE3_TEXT);
$handlers = $this->preparedSQL->selectHandlers->execute(); $handlers = $this->preparedSQL->selectHandlers->execute();
$result = null; $result = null;
if($handlers !== false and $handlers !== true){ if($handlers instanceof SQLite3Result){
$call = array(); $call = array();
while(($hn = $handlers->fetchArray(SQLITE3_ASSOC)) !== false){ while(($hn = $handlers->fetchArray(SQLITE3_ASSOC)) !== false){
$call[(int) $hn["ID"]] = true; $call[(int) $hn["ID"]] = true;
@ -534,29 +534,28 @@ class PocketMinecraftServer{
$this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT); $this->preparedSQL->selectActions->bindValue(":time", $time, SQLITE3_FLOAT);
$actions = $this->preparedSQL->selectActions->execute(); $actions = $this->preparedSQL->selectActions->execute();
if($actions === false or $actions === true){ if($actions instanceof SQLite3Result){
return; while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){
} $cid = $action["ID"];
while(($action = $actions->fetchArray(SQLITE3_ASSOC)) !== false){ $this->preparedSQL->updateAction->reset();
$cid = $action["ID"]; $this->preparedSQL->updateAction->bindValue(":time", $time, SQLITE3_FLOAT);
$this->preparedSQL->updateAction->reset(); $this->preparedSQL->updateAction->bindValue(":id", $cid, SQLITE3_INTEGER);
$this->preparedSQL->updateAction->bindValue(":time", $time, SQLITE3_FLOAT); $this->preparedSQL->updateAction->execute();
$this->preparedSQL->updateAction->bindValue(":id", $cid, SQLITE3_INTEGER); $schedule = $this->schedule[$cid];
$this->preparedSQL->updateAction->execute(); if(!is_callable($schedule[0])){
$schedule = $this->schedule[$cid]; $return = false;
if(!is_callable($schedule[0])){ }else{
$return = false; $return = call_user_func($schedule[0],$schedule[1],$schedule[2]);
}else{ }
$return = call_user_func($schedule[0],$schedule[1],$schedule[2]);
}
if($action["repeat"] === 0 or $return === false){ if($action["repeat"] === 0 or $return === false){
$this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";"); $this->query("DELETE FROM actions WHERE ID = ".$action["ID"].";");
$this->schedule[$cid] = null; $this->schedule[$cid] = null;
unset($this->schedule[$cid]); unset($this->schedule[$cid]);
}
} }
$actions->finalize();
} }
$actions->finalize();
} }
public function event($event,callable $func){ public function event($event,callable $func){