Skip to content

Commit

Permalink
Merge pull request #35 from khepin/updating_objects
Browse files Browse the repository at this point in the history
Updates through query builder fixes #32
  • Loading branch information
jmikola committed Jun 27, 2012
2 parents 98162cd + 6055677 commit 1ec2620
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions en/reference/query-builder-api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ Change a users password:
<?php
$dm->createQueryBuilder('User')
->update()
->field('password')->set('newpassword')
->field('username')->equals('jwage')
->getQuery()
Expand All @@ -506,6 +507,7 @@ tell it the update is not an atomic one:
<?php
$dm->createQueryBuilder('User')
->update()
->field('username')->set('jwage', false)
->field('password')->set('password', false)
// ... set other remaining fields
Expand Down Expand Up @@ -557,6 +559,7 @@ exists:
<?php
$dm->createQueryBuilder('User')
->update()
->field('login')->unsetField()->exists(true)
->getQuery()
->execute();
Expand All @@ -572,6 +575,7 @@ Append new tag to the tags array:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->push('tag5')
->field('id')->equals('theid')
->getQuery()
Expand All @@ -588,6 +592,7 @@ Append new tags to the tags array:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->pushAll(array('tag6', 'tag7'))
->field('id')->equals('theid')
->getQuery()
Expand All @@ -604,6 +609,7 @@ Add value to array only if its not in the array already:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->addToSet('tag1')
->field('id')->equals('theid')
->getQuery()
Expand All @@ -621,6 +627,7 @@ already:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->addManyToSet(array('tag6', 'tag7'))
->field('id')->equals('theid')
->getQuery()
Expand All @@ -637,6 +644,7 @@ Remove first element in an array:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->popFirst()
->field('id')->equals('theid')
->getQuery()
Expand All @@ -649,6 +657,7 @@ Remove last element in an array:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->popLast()
->field('id')->equals('theid')
->getQuery()
Expand All @@ -665,6 +674,7 @@ Remove all occurrences of value from array:
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->pull('tag1')
->getQuery()
->execute();
Expand All @@ -678,6 +688,7 @@ in the Mongo docs.
<?php
$dm->createQueryBuilder('Article')
->update()
->field('tags')->pullAll(array('tag1', 'tag2'))
->getQuery()
->execute();
Expand Down

0 comments on commit 1ec2620

Please sign in to comment.