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.

Adding simple singleton pdo connection

Hi!

Although ORM is good and it does what I need in 80% cases but in few areas I do need simple sql to run advanced query or simple for ajax search (dat orm search is a bit slow) for this purpose.

Is there any link on elegant inserting pdo connection to the di and using it?



46.8k
Accepted
answer

Call getInternalHandler on the Phalcon connection to have it return a PDO. That way Phalcon can set everything up with the dependency injector.

The ORM isn't going to be slow as it uses SQLite tech and its code is written in Zephyr. Also the only thing that I've found won't work for me is complicated joins with multiple tables and the solution for that is to disable implicit joins with enable_implicit_joins on the project level with Model::setup or just for the one query.

Unless you really know what you are doing it is probably too early to say if Phalcon is too slow for you. You can cache the table meta data and searches as well.