database = $in_database; $this->get_static = function($name) { return self::$$name; }; } public function get_all_devices($only_with_location) { $s = $this->get_static; $sql = "SELECT {$s("column_device_id")} AS id, {$s("column_device_name")} AS name, {$s("column_lat")} AS latitude, {$s("column_long")} AS longitude FROM {$s("table_name")}"; if($only_with_location) $sql .= "\nWHERE {$s("column_lat")} IS NOT NULL AND {$s("column_long")} IS NOT NULL"; $sql .= ";"; return $this->database->query($sql)->fetchAll(); } }