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

MySQL optimizations. what happens behind the scenes?

Hi.

I'm using the latest Phalcon build and I need a few tips regarding MySQL optimization and general ORM questions:

  1. Is there any kind of type mapping? so int's will be int and not a string.
  2. How can I use the default colunm values normally? can it happen without the Raw-something shit I found on Google?
  3. Not really related but is there a Phalcon PHP7 progress bar somewhere? I found some github discussions but no one has an updated timeline.
  4. I configured my relational database both in MySQL and inside the model (using hasMany/belongsTo), but I couldn't find out what happens behind the scenes when you use it? I'll take the robots example from the docs https://docs.phalcon.io/en/latest/reference/models.html

$robots = Robots::find(); foreach ($robots as $robot) $robotsParts = $robot->getRobotsParts();

Does it query every time I call getRobotsParts or automatically joins allways. How can I optimize it? where can I know more about it and how it works?

P.S All optimization tips are welcome :)

Thanks.

Optimization and ORM are pretty much opposites. They seek to satisfy different ends. One is efficiency of code operation. One is efficiency of coding.

In your example (Please read the Markdown FAQ for properly formatting code.), Phalcon would execute a query for each iteration of the loop.