function execute($query, $tablename = null, $object = null) { if (isset($this->result) && !is_null($this->result)) { $this->free_result(); } $this->result = mysql_query($query, $this->dblink); require_once 'session.php'; if (isset($_SESSION["query"][substr($query, 0, 6)])) { Session::incrementQueryCounter(substr($query, 0, 6)); } $this->info = mysql_info($this->dblink); $this->errno = mysql_errno($this->dblink); $this->error = mysql_error($this->dblink); if ($this->errno()) { $this->display_error("DBManager::execute() - query " . $query); } if ($object == LOGMANAGER) { return; } $this->query_type = substr($query, 0, 6); //DEBUG if (DEBUG) { //echo "<p>" . $this->query_type . ": " . $this->info(); //DEBUG //echo "<br /><font color='green'>" . var_export($this->result, true) . "</font>"; echo "<p>" . $query . "</p>"; //DEBUG } if ($this->query_type == "SELECT") { $this->num_rows = mysql_num_rows($this->result); } else { $this->num_rows = 0; } if ($this->query_type == "INSERT") { $this->last_inserted_id = mysql_insert_id($this->dblink); } else { $this->last_inserted_id = false; } if ($this->query_type == "INSERT" || $this->query_type == "DELETE") { $this->affected_rows = mysql_affected_rows($this->dblink); } else { $this->affected_rows = 0; } if ($this->query_type == "UPDATE") { $this->affected_rows = intval(substr($this->info(), strpos($this->info(), "Changed: ") + 9, strpos($this->info(), "Warnings: ") - 1 - 9)); } //DEBUG if (DEBUG) { echo "<br /> aff = " . $this->affected_rows() . " | num = " . $this->num_rows() . " | lid = " . $this->last_inserted_id() . "</p>"; } //DEBUG //END DEBUG if ($this->affected_rows() > 0) { require_once "session.php"; require_once "manager/LogManager.php"; $user = Session::getUser(); if (is_subclass_of($user, "User")) { LogManager::addLogEntry($user->getID(), substr($query, 0, 6), $tablename, $object); } } return $this->result; }