Pierre Dusquel
Pierre Dusquel

Reputation: 35

Neo4j find only 10 movies

I found today in slack neo4j that it is possible to use ogm in php.

https://github.com/graphaware/neo4j-php-ogm

I use the examples demonstrated in test folder with person and movie table.

But I want to have only 10 movies, but I now have all movies.

This is my code in application :

$movies = $em->getRepository(Personne::class)->findAll();

Thanks already for responses.

Upvotes: 2

Views: 108

Answers (1)

Christophe Willemsen
Christophe Willemsen

Reputation: 20185

Wow that's impressive, this library was released this morning. Thanks for already using it.

I assume you have a typo in your question and that the class passed to the entity manager should be a movie class.

So yes, this is possible to only return a subset of all the Movie nodes and even order them :

$only10Movies = $em->getRepository(Movie::class)->findAll(['limit' => 10]);

You can also order them if you want :

$movies = $em->getRepository(Movie::class)->findAll(['order' => array('title' => BaseRepository::ORDER_ASC)]);

The documentation is also available here :

https://github.com/graphaware/neo4j-php-ogm/blob/1.0/docs/01-intro.md

Upvotes: 3

Related Questions