Hi, i need put a object Phalcon\Mvc\Model\Query\Builder into the session, but i receive a exception: Exception: Serialization of 'Closure' is not allowed! Can i resolve this problem someway?
Thanks
|
Jun '16 |
8 |
2009 |
0 |
This can't be resolved because the object has an anonymous function (otherwise known as a closure) and they cannot be serialized.
The right question was asked - why even put it in a session? The Builder itself doesn't store the results of the query, so you're not saving a database trip (or trips). Sure, storing the Builder in Session would prevent it from being built repeatedly, but with Phalcon, the amount of processor cycles that takes is so minimal, it's practically a non-issue for the vast majority of sites.
Dylan anderson - you forgot about serializing/unserializing, even if it could be stored in session - the difference would be none or even it would be slower. The REAL difference could be make if we could have REAL FASTCGI in php - like we have whole application started after starting server - and all requests are parsed by it and response is returned - but application is never rebuiled, just response is cleaned and waiting for another requests. There is such a project for php which speed it up by really majority of time but it has a lot of issues.
@Jurigag: PHP has FPM. What you're talking about is actual application cache - and such thing perhaps can be achivied with i.e. Memcached. But let's focus on question here - putting an object Phalcon\Mvc\Model\Query\Builder into the session is just NO NO.
No. Im not talking about application cache. You can't achieved it with memcached. Im talking about application just iniciated once, and it's listening for requests and returning responses. Either FPM or Memcache can git it to you. I'm talking about this - https://github.com/PHPFastCGI