find objectId in PHP

Good Day,

I have a table Merchant. I cannot find a Merchant using objectId, here is the code:

$merchant = Backendless::Persistence->findById( “Merchant”, ‘C90D7AF9-3A84-B9EA-FFD4-60AD3F752900’);

end the error is:

Parse error: syntax error, unexpected ‘->’ (T_OBJECT_OPERATOR) in

Regards,

Hi Pluto,

Try following code:

$merchant = Backendless::$Persistence->findById( "Merchant", 'C90D7AF9-3A84-B9EA-FFD4-60AD3F752900');

Regards,

Denys

I tried the code but received the following error:

Fatal error: Uncaught exception ‘backendless\exception\BackendlessException’ with message ‘It is impossible get entity name, use the method “…->of(“entity_name”)->…” to set a specific entity.’ in backendless\src\services\Persistence.php

Sorry. Try this one

$merchant = Backendless::$Persistence->of(“Merchant”)->findById(“C90D7AF9-3A84-B9EA-FFD4-60AD3F752900”);

Thanks its working. But how can I update the merchant? I have a field which is called merchantName

$merchant = Backendless::$Persistence->of(“Merchant”)->findById(“C90D7AF9-3A84-B9EA-FFD4-60AD3F752900”);

//this one throws an error
$merchant->setMerchantName(‘New Name’);
Backendless::$Persistence->update( $merchant );

Error:
Fatal error: Call to a member function setMerchantName()

Internal task has been created for this issue.

Regards,

Denys

thanks. i will wait for a possible solution.

thanks. i will wait for a possible solution

Good Day,

Any update? or any other solution?

Appreciate a lot.

Thanks

Hi Pluto,

Changes are available on github https://github.com/Backendless/PHP-SDK
Please, be sure class Merchant inherited form class Data or you should implement method setMerchantName by yourself. You can also use setProperty method, like $merchant->setProperty(‘merchantName’, ‘New Name’).

Regards,

Denys

HI Denys,

I tried your suggestion:

$merchant = Backendless::$Persistence->of(“Merchant”)->findById(“5787E8CF-9135-5F8F-FFC5-FD91EB7F7F00”);
$merchant->setProperty(“merchantName”,“New Name”);
Backendless::$Persistence->of(“Merchant”)->update( $merchant );

But giving me this error:
Fatal error: Call to a member function setProperty() on array

and here is my Merchant class:
class Merchant extends Data

HI Denys,

I tried your suggestion:

$merchant = Backendless::$Persistence->of(“Merchant”)->findById(“5787E8CF-9135-5F8F-FFC5-FD91EB7F7F00”);
$merchant->setProperty(“merchantName”,“New Name”);
Backendless::$Persistence->of(“Merchant”)->update( $merchant );

But giving me this error:
Fatal error: Call to a member function setProperty() on array

and here is my Merchant class:
class Merchant extends Data

Good Day, Any update of this problem? Best Regards

Hi Pluto,

Please, try following
$merchant[ “merchantName” ] = “New Name”;$merchant[ “table-name” ] = “Merchant”;
Backendless::$Persistence->of(“Merchant”)->update( $merchant );

Regards,

Denys

HI Denys,

It works great. Thanks for the support. Appreciate it a lot.

Regards,
Pluto