I'm trying to serialize a Doctrine_query object in Symfony :
var_dump(serialize($this->pager->getQuery()));
The result is :
string(2) "N;"
What am I doing wrong?
I'm trying to serialize a Doctrine_query object in Symfony :
var_dump(serialize($this->pager->getQuery()));
The result is :
string(2) "N;"
What am I doing wrong?
You can not serialize every object in PHP. Objects themselves - by implementing the Serializeable
interface PHP Manual - can protect themselves from being serialized for example.
They return a NULL
value then (or don't return anything which is then NULL
in PHP). And that's exactly the contents of your serialized string: a serialized NULL
(N;
).
And there are even some build-in classes that go even further than that. But it applies as well to user-defined classes and build-in classes: Some of them are not available for serialization.
One example of a built-in class that can not be serialized in PHP is DOMDocument
, however it is possible to add the functionality as the following question demonstrates: