I made a simple PHP app based on this example in the docs:
https://backendless.com/documentation/data/php/data_relations_save_update.htm
I did the exact same thing in my code yet I’m still getting this error:
"Uncaught
exception ‘backendless\exception\BackendlessException’ with message
‘Backendless API return error: Missing ___class property for entity:
__relations Error code:1020’ .
class Cinema {
public $Name;
public $Phone;
public $Location;
public $__relations = [
‘Location’ => ‘LO’
];
public function getName() {
return $this->Name;
}
public function setName( $Name ) {
$this->Name = $Name;
}
public function getPhone() {
return $this->Phone;
}
public function setPhone( $Phone ) {
$this->Phone = $Phone;
}
public function getLocation() {
return $this->Location;
}
public function setLocation($Location) {
$this->Location = $Location;
}
}
THis is my code.CAnt see problem need help with error.
you can not have such properties in your class
public $__relations = [
'Location' => 'LO'
];
you can have ralations only for some objects. Try to use the exact example from document
In the example ‘Location’ is the field in my table and LO is the php file wich contains the class of relational table same as the case in of
public $__relations = [
‘address’ => ‘test\models\Address’
];
I cant understand what you mean by ‘use the exact from document’.
you should write something like this
public $__relations = [ new Location()];
For that i m getting unexpected ‘new’.
Did you meant that for php?
I meant php.
use this code
class Location {
public $test;
}
class Cinema {
public $Name;
public $Phone;
public $Location;
public $__relations;
}
$cinema = new Cinema;
$location = new Location();
$cinema->$__relations = [$location];
Thanks for the help but it is not working man ,firstly the code is not working if $__relations is defined after the end of Cinema class and if it is put inside it gives error as unexpected ‘$cinema’ expecting a function.
why do you define $__relations field? do you have such column in your table ?
i meant
$cinema = new Cinema;
$location = new Location();
$cinema->$__relations = [$location];
These three lines
If i write them outside Cinema class it shows error about undefined variable $__relations and if inside cinema class it shows $cinema not expected, a function is expected.