Comments (3)
Those are two different queries, and you can't use them in the way you mentioned.
First query when translated to RQL, it will be:
$session->query(Site::class)
->whereEquals("userId", $userId)
->toList();
from "Sites"
where userId == "UserID"
and if you create a query with count()
, it will create RQL like:
$session->query(Site::class)
->whereEquals("userId", $userId)
->count();
from "Sites"
where userId == "UserID" limit 0, 0
The method count()
will return just an integer value. PHP client will send this query to the server to get the number of documents, but it will not return any document from the server. More about count can be found in the documentation: https://ravendb.net/docs/article-page/5.4/csharp/client-api/session/querying/how-to-count-query-results
It would be best to leave out the count() part for the mentioned case because 'toList()' method will always return an array.
from ravendb-php-client.
Another thing to consider is that RavenDB doesn't need a separate query.
You can use the getQueryStatistics()
to get the results in one remote call.
$statsRef = new QueryStatistics();
$query = $session->query(Site::class)->whereEquals("userId", $userId);
$results = $query->statistics($statsRef)->toList();
$totalResults = $statsRef->getTotalResults();
from ravendb-php-client.
Thank you both of you! It just felt like an issue, because the call to $query->count()
overrides the $query variable, which it before didn't do. But this resolves with using statistics or changing our approach a little bit.
from ravendb-php-client.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ravendb-php-client.