public function getByID($id, $fields = NULL, $safe_fields = false) { if (is_null($fields)) { $fields = $this->default_fields; $safe_fields = true; } $fields = DBHandler::createFieldString($fields, "", $safe_fields); $res = $this->dbh->query("SELECT {$fields} FROM organization_user WHERE organization_id = ? AND id = ?", array($this->organization_id, $id)); if (is_array($res) && count($res)) { return $res[0]; } }
public function getLastInsertID($table, $where = array()) { $table_whitelist = array("team", "organization_user", "feed_entry"); if (!in_array($table, $table_whitelist)) { return array(); } $where["organization_id"] = $this->organization_id; if ($table !== "organization_user") { $where["organization_domain_id"] = $this->organization_domain_id; } $fields = DBHandler::createFieldString($fields, "t", $safe_fields); $where = DBHandler::createWhereString($where, "t"); $res = $this->dbh->query("SELECT MAX(t.`id`) as id FROM `{$table}` t WHERE {$where[0]}", $where[1]); return isset($res[0]) ? $res[0]['id'] : 0; }