We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

MongoDB is only running one query.

$symbols          = SymbolsModel::find([['symbol' => 'AAPL']]);
foreach ($symbols as $symbol) echo $symbol->symbol, "\n";
print '<hr>';
$symbols          = SymbolsModel::find([['symbol' => 'AAPL']]);
foreach ($symbols as $symbol) echo $symbol->symbol, "\n";

What could be causing the second query from not printing results at all? Its like it only runs the first query and prints fine and it then forgets the rest. It doesnt halt. the entire script finishes. Doesnt matter what the second query is whether its the same or not. Second one just returns an empty array. Been stuck on this for hours and cant figure out whats causing it.

So apparently if you do the following it causes the issue I describe...

class Symbols extends MongoCollection {
public function initialize(){
  $this->setSource('data_symbols');
}

Seems like a nasty bug. When i change it to just 'symbols', it works fine. The _ in the source name breaks it.

So apparently if you do the following it causes the issue I describe...

class Symbols extends MongoCollection {
public function initialize(){
 $this->setSource('data_symbols');
}

Seems like a nasty bug. When i change it to just 'symbols', it works fine. The _ in the source name breaks it.

It's not the "_" sign, whenever your Model name and collection name are difference then you will encountered this bug. Solution here: https://forum.phalcon.io/discussion/11391/mongo-odm-cannot-run-two-queries-on-the-same-collection