K
K
krispey1022021-06-12 02:19:10
1C-Bitrix
krispey102, 2021-06-12 02:19:10

Bitrix how to write a new method for working with database fields in ORM?

The database has a DESCRIPTION field
to work with this field in the orm.annotations.php file there are several methods:
* @method \Jakiro\EO\GameMode setDescription(\string|\Bitrix\Main\DB\SqlExpression $description)
* @method \Jakiro\EO\GameMode resetDescription()
* @method \Jakiro\EO\GameMode unsetDescription()
And by submitting the form on the site, using this code, you can set the received values ​​in the db field
->setDescription($ob->description)
How to create one more field of your own and write such methods so that they work like ->setDescription($ob->description)?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
PetrPo, 2021-06-12
@krispey102

@method is not a method, it's an annotation that is needed for ide.
setDescription - all such calls are handled via the __call magic method

How to create another custom field

Just like for any Bitrix orm entity
write such methods so that they work like ->setDescription($ob->description)

You don’t need to prescribe anything (just add a field to the entity), only as indicated above, annotations for ide (can be generated through the console utility) - but this is not a prerequisite, it will work without them.
Everything is described in the documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question