Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Sokil
@sokil
just add list of id of some entity to field of another entity
many-to-many relation in relational databases use intermediate table, so just move this table to corresponding document, and that's all
Sokil
@sokil
hm, but i have idea of helper for this case) in some of next releases this feature will be implemented
Sokil
@sokil
You can subscribe to this issue to get notification when this feature will be implemented - sokil/php-mongo#21
Huy Doan
@rgv151
I store array of id too but I have problem w/ getter/setter I can't manipulation them directly from document
Sokil
@sokil
why?
$document->push('someRelField', $relatedDocument->getId())
$document->pushEach('someRelField', [$relatedDocument1->getId(), $relatedDocument2->getId()])
This message was deleted
Huy Doan
@rgv151

I have to referenced refField to a variable, manipulate them and set it back to the document.

From the code above, how to add/remove relatedDocument to the list?

Huy Doan
@rgv151

I'm trying to clear roles, and re-push them but I got Exception

$user->set('roles', []);
$user->pushFromArray('roles', $roles);
Uncaught exception 'MongoCursorException' with message 'localhost:27017: Cannot update 'roles' and 'roles' at the same time'

same error with $user->unsetFields('roles');

Huy Doan
@rgv151
nvm, just set them directly..
$user->set('roles', $roles);
Sokil
@sokil
it's just because you try to $set and $pushEach same field at the same time. Use set, if you want to rewrite field, or pushEach if you want tu push some values to existed field.
Jakob Murko
@sraka1
Hi @sokil
Here?
Anyways, I added a new issue. Would love to help out to get this sorted out as soon as possible.
Hope you'll have some time tomorrow to take a look at it. Cheers!
Jakob Murko
@sraka1
@sokil here?
Sokil
@sokil
Look at issue
Jakob Murko
@sraka1
Hey
One question
I'm not really sure I properly understand the caching component
You're binding it to a collection
But then you write arbitrary key/value pairs?
How does it differ from a standard cache such as memcached/redis?
Thanks
Sokil
@sokil
There is no difference. Its just cache based on mongodb. And it has some methods to invalidate cache by tags in the box.
Sokil
@sokil
And collection used as storage for values. If value is array, it may be of any structure
Daniel Coulbourne
@DanielCoulbourne
@sokil you here?
Sokil
@sokil
you can leave questions here evan i'm offline
Dan Rec
@DanRec46
i've used $collection->getDistinct('fieldname'); ..... how to use distinct with where ?
Sokil
@sokil
Before 1.12.6 allowed only Expression object, since this version - arrays and callables also. Some examples at https://github.com/sokil/php-mongo/blob/master/README.md#distinct-values
mayurmakwana
@mayurmakwana
Hello
i followed this step but
not working script what should i do for it ??
Sokil
@sokil
can you explain more concrete? Your link about installing MongoDB on Ubuntu, this chat is about ODM for MongoDB written in PHP
Vinícius
@vini-developer
hello, anybody here?
Sokil
@sokil
yes)
Neri J. Jakubowski Junior
@nerijunior
@sokil Congratulations! This package is awesome!
Sokil
@sokil
Glad to hear that)
Neri J. Jakubowski Junior
@nerijunior
@sokil How can I set the cursor timeout? like: $cursor = $collection->find();
I tried $cursor->timeout(-1) but without effect.
Sokil
@sokil
add and issue and a'll add this in next release
rupesh1910
@rupesh1910
can anyone help me sort my problem
i want to update my collection 2 i.e fetch value from collection 1
i tried $collection1 = $collection1->find(), $collection2->update($collection1)
Sokil
@sokil
can you explain your question?
RicardoMaGo
@RicardoMaGo
Hello, someone here?
Sokil
@sokil
yes)
Ghost
@ghost~5bfff5bcd73408ce4fb0743d
Hi.
Dmitriy, could you please provide an example of document class?
Sokil
@sokil

Your question is vary abstract and complex).

You don't need document class at all:

$client->getDatabase('databaseName')->getCollection('collectionName')->getDocument('someId')->get('some.field');

You need class for you document if you need some validation, default values, complex getters and setters, etc...

Simple document:

<?php 
namespace Vendor\Document; 
use \Sokil\Mongo\Document; 
class SomeDocument extends Document { }

Then read manual or ask more concrete question...

Ghost
@ghost~5bfff5bcd73408ce4fb0743d
Thanks for your answer.