Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

How many queries to save entire resultset


I'm trying to reduce the number of DB queries that occur when performing an operation on every model of a resultset. If I iterate over a result and perform the same operation, does phalcon perform man small db queries, or does it create a larger one?


$results = Model::find($conditions);
foreach($results as $result) {
    $result->status = "changed";

Or should i create a phql query to do this, or is there something else I should be doing to reduce the number of DB calls?


Well- in that example u have 1 query to get results and 1 query for every result to save new status. I do not know what is best, depends of your need and project requirements. Consider situation when results is more than few lines- then maybe query will be better to do that job. But for me- i prefer simplies ways.

Good luck :)