0

Im looking to see if anyone can shed some light on a problem im having.

In my collection Y, I have a field called ADJU, which has stored in it, the serialised PHP array of MongoIDs.

One example field is "a:1:{i:0;a:1:{s:4:\"MBID\";C:7:\"MongoId\":24:{4f2c5b9bb9a21d5010000005}}}"

The parameter im passing in is "4f2c5b9bb9a21d5010000005"

public function read_adjudicating(MongoID $account_identifier){
    $regexObj = new MongoRegex("/".$account_identifier->__toString()."/");
    var_dump($regexObj);
    $result = $this->connection->X->Y->find(array('ADJU' => $regexObj), array('__id'));
    var_dump($result);

Can anyone work out why it is giving me 0 records, when as you can see, one example definately has it?

Thanks for your help!

3
  • On a side note, there are no php errors or anything and my suspicions are on the use of "s Commented Mar 13, 2012 at 15:25
  • 1
    why would you ever store a serialized string in a nosql datastore? Commented Mar 13, 2012 at 15:58
  • Part proof-of-concept, and the data came from MySQL on a previous install Commented Mar 13, 2012 at 22:14

1 Answer 1

1

Well, it's not the query:

db.illogical.insert({'ADJU': "a:1:{i:0;a:1:{s:4:\"MBID\";C:7:\"MongoId\":24:{4f2c5b9bb9a21d5010000005}}}"})
db.illogical.find({'ADJU': /4f2c5b9bb9a21d5010000005/})
{ "_id" : ObjectId("4f605b9e5d2b96c06d2adb27"), "ADJU" : "a:1:{i:0;a:1:{s:4:\"MBID\";C:7:\"MongoId\":24:{4f2c5b9bb9a21d5010000005}}}" }

Which means the php code you've written doesn't correspond to the query you expect, or the data isn't in the format you expect.

Rather than investigate why though - you'd be better off IMO either updating the script you used to import the data from mysql to deserialize before inserting to mongo - or write a (php) script to read the already-serialized-in-mongo data, deserialize it - and save it again.

Sign up to request clarification or add additional context in comments.

1 Comment

Turns out, I was using var_dump to debug, which doesnt work with an iterator (MongoCollection). When i ran iterator_to_array before it, it worked fine. Thanks for the tips though, its much appreciated!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.