arangodb / arangodb-php

PHP ODM for ArangoDB
https://www.arangodb.com
Apache License 2.0
183 stars 43 forks source link

Affected docs count method #179

Closed razvanphp closed 9 years ago

razvanphp commented 9 years ago

Today I came across this and I think it should be somehow included in the SDK.

$result = $stmt->execute()->getMetadata();
return (isset($result['extra'][Cursor::ENTRY_STATS]['writesExecuted'])) ?
           $result['extra'][Cursor::ENTRY_STATS]['writesExecuted'] : 0;

Thank you!

frankmayer commented 9 years ago

Just do be on the same page, are you, with "somehow", proposing to introduce a getExtra() method, or want to make sure that a key/value pair is always present? If it's the second, it should probably not be handled on the client side, but be made sure that it is included from the server side.

razvanphp commented 9 years ago

I would like more something like

$count = $stmt->execute()->getAffectedRows();

but your idea is also good :+1:

frankmayer commented 9 years ago

I think you have a point here. :+1: How about both?

$extra = $stmt->execute()->getExtra(); for a direct access to the extras

and something like

$writesExecuted = $stmt->execute()->getWritesExecuted(); or $affectedDocs = $stmt->execute()->getAffectedDocs();

for a chainable and more direct access to this more widely used value.

BTW, I purposely left out "getAffectedRows" as we're not dealing with rows :smile:

razvanphp commented 9 years ago

Haha, true, sorry, strong mysql background here, I updated the title.

frankmayer commented 9 years ago

...yes, me too... no worries :smile:

jsteemann commented 9 years ago

I implemented the following methods in the 2.5 and devel branches of the driver:

I also created a v2.5.1 tag which contains the changes.

frankmayer commented 9 years ago

Nicely done, Jan. As always. I would have done it over the weekend, but you were faster ;) I'm slowly getting back into it again, though, and will be contributing again, so you can keep your focus on the DB.

jsteemann commented 9 years ago

Thanks.

razvanphp commented 9 years ago

Wow, that was fast, I already implemented it, looks great now.

Thank you!