query() public method

Generates query parameters for a related object (or objects) for the given object connected to it by this relationship.
public query ( object $object ) : object
$object object The object to get the related data for.
return object Returns the object(s) for this relationship.
Example #1
0
 /**
  * Tests that queries are correctly generated for each relationship/key type.
  */
 public function testQueryGeneration()
 {
     $relationship = new Relationship(array('name' => 'Users', 'type' => 'hasMany', 'link' => Relationship::LINK_KEY_LIST, 'from' => 'my\\models\\Groups', 'to' => 'my\\models\\Users', 'key' => array('users' => '_id'), 'fieldName' => 'users'));
     $this->assertNull($relationship->query((object) array()));
     $keys = array(1, 2, 3);
     $expected = array('conditions' => array('_id' => $keys), 'fields' => null);
     $this->assertEqual($expected, $relationship->query((object) array('users' => $keys)));
 }