lphuberdeau / Neo4j-PHP-OGM

A doctrine2 style library to access neo4j graphs
156 stars 45 forks source link

get the generated query as a string #15

Closed bazo closed 12 years ago

bazo commented 12 years ago

is there any way how to get the generated query as a string? i want to build a plugin for the framework i'm using that would show all queries with evaluated parameters as a single final string.

lphuberdeau commented 12 years ago

Some parameters are built into the query, but most of them never are built into the query as the REST interface allows to send parameters as a separate array, similar to a prepared statement in SQL.

If you want to intercept the queries, the best place would be in gremlinQuery and cypherQuery in the entity manager. You could set up some event handling in there to bind listeners.

I think measuring the duration of queries would be a good thing.

bazo commented 12 years ago

measuring the qeury duration along with the query is exactly what i had on my mind. it looks easy to implement.

bazo commented 12 years ago

where do i have to create the tmp folder so that i can run the tests? all of them are failing because of this

lphuberdeau commented 12 years ago

It uses the system /tmp at this time. You might want to make it configurable in the php.ini as @kwattro did.

https://github.com/kwattro/Neo4j-PHP-OGM/commit/38cca88b5373f4b43b450d5506bf5f68807b81c8

ikwattro commented 12 years ago

@lphuberdeau Do you want that I add it to the phpunit.xml ?

bazo commented 12 years ago

i'm on windows. but i figured it out

bazo commented 12 years ago

looks like, at least for cypher queries, the parameters in queries get replaced by their values and the final string is sent to the server. dump of $arguments always gives me empty array.

i haven't tried gremlin, because i don't really get that language yet.

has anyone a sample dump of this $arguments?

lphuberdeau commented 12 years ago

It depends on the type of argument. When providing entities or integer, they get replaced, otherwise they go as arguments.

bazo commented 12 years ago

ok, i got it all working now nicely