Sokil\Mongo\Client::createPersistence PHP Method

createPersistence() public method

Create new persistence manager
public createPersistence ( ) : Sokil\Mongo\Persistence
return Sokil\Mongo\Persistence
    public function createPersistence()
    {
        // operations of same type and in same collection executed at once
        if (version_compare($this->getVersion(), '1.5', '>=') && version_compare($this->getDbVersion(), '2.6', '>=')) {
            return new Persistence();
        }
        // all operations executed separately
        return new PersistenceLegacy();
    }

Usage Example

 public function setUp()
 {
     $this->client = new Client();
     $this->persistence = $this->client->createPersistence();
     $this->collection = $this->client->getDatabase('test')->getCollection('phpmongo_test_collection');
 }