I believe the issue is caused by `$this->results[$queryKey]` being overwritten when you run a new query inside `getCategory()`.
So when you call `$this->fpdb->query(...)` in `getCategory()`, it updates the `$this->results` map and the current query key, which breaks the loop in `getProperties()` because `fetch_object()` now references the subquery instead of the original result set.
To fix this, you can store the result of the main query in a temporary variable before entering the loop, like this:
function getProperties() {
$s = "SELECT * FROM properties";
$result_set = $this->fpdb->query($s, return_result: true); // store raw result
$result = [];
while ($r = mysqli_fetch_object($result_set, Property::class)) {
$r->category = $this->getCategory($r->cid);
$result[] = $r;
}
return $result;
}
This way, even if `getCategory()` runs a subquery internally, it won't interfere with the loop iterating over your original `$result_set`.