waltertamboer/doctrine-criteria-serializer

A small PHP library that can be used to serialize a Doctrine Criteria object.

dev-master 2014-11-24 23:09 UTC

This package is not auto-updated.

Last update: 2024-11-19 04:00:26 UTC


README

Build Status

A small PHP library that can be used to serialize a Doctrine Criteria object.

Example

To serialize a criteria, simply call CriteriaSerializer::serialize.

<?php

use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\CriteriaSerializer;

$criteria = Criteria::create();
$criteria->where($criteria->expr()->contains('field2', '2'));

$serializer = new CriteriaSerializer();
$serializedString = $serializer->serialize($criteria);

To get a Criteria object again, simply call CriteriaSerializer::unserialize.

<?php

use Doctrine\Common\Collections\Criteria;
use Doctrine\Common\Collections\CriteriaSerializer;

$serializer = new CriteriaSerializer();
$criteria = $serializer->unserialize($data);