Overview

Namespaces

  • LeanCloud
    • Engine
    • Operation
    • Storage
    • Uploader

Classes

  • ACL
  • AppRouter
  • Bytes
  • Client
  • File
  • GeoPoint
  • LeanObject
  • MIMEType
  • Push
  • Query
  • Region
  • Relation
  • Role
  • RouteCache
  • SaveOption
  • SMS
  • User

Exceptions

  • BatchRequestError
  • CloudException
  • Overview
  • Namespace
  • Class

Class Relation

Many-to-many relationship for LeanObject

A relation consists of an array of objects, of which items can be added to, and removed from. Each field could only have one kind of object.

Namespace: LeanCloud
Located at LeanCloud/Relation.php
Methods summary
public
# __construct( LeanCloud\LeanObject $parent, string $key, string $className = null )

Initialize relation

Initialize relation

Build a relation on parent field. It shall be rarely used directly, use $parent->getRelation($key) instead.

Parameters

$parent
Parent object
$key
Field key on parent object
$className
ClassName the object relatedTo
public array
# encode( )

Encode to JSON representation of relation.

Encode to JSON representation of relation.

Returns

array
public
# setParentAndKey( LeanCloud\LeanObject $parent, string $key )

Attempt to set and validate parent of relation

Attempt to set and validate parent of relation

Parameters

$parent
Parent object of relation
$key
Field key

Throws

RuntimeException
public string
# getTargetClassName( )

Get target className of relation

Get target className of relation

Returns

string
public
# add( object|array $objects )

Add object(s) to the field as relation

Add object(s) to the field as relation

Parameters

$objects
LeanObject(s) to add
public
# remove( object|array $objects )

Remove object(s) from the field

Remove object(s) from the field

Parameters

$objects
LeanObject(s) to remove
public LeanCloud\Query
# getQuery( )

Query on the target class of relation

Query on the target class of relation

Returns

LeanCloud\Query
public LeanCloud\Query
# getReverseQuery( LeanCloud\LeanObject $child )

Query on the parent class where child is in the relation

Query on the parent class where child is in the relation

Parameters

$child
Child object

Returns

LeanCloud\Query
API documentation generated by ApiGen