K
K
krispey2021-08-26 14:59:01
ORM
krispey, 2021-08-26 14:59:01

Bitrix ORM related fields not working?

There is a self-written ORM. There is a "product" on the page and inside the "calendar" page where you can add different time points.
When choosing a time point and saving, the changed values ​​of the "product" and "calendar" are saved in the database through the associated table separately for the calendar
. But for some reason, the "calendar" values ​​​​are not saved in the database. Item values ​​are saved.
Description of the "product" column

class GameModeTable extends DataManager {

    public static function getMap(){

        return [
            new IntegerField('ID',[
                'primary' => true,
                'autocomplete' => true
            ]),
            new BooleanField('CUSTOM_SCHEDULE_SELECT'),
            (new OneToMany('CUSTOM_SCHEDULES', CustomScheduleTable::class, 'GAMEMODE'))->configureJoinType('left'),
        ];
    }
}

Description of the "calendar" table
class CustomScheduleTable extends DataManager {

    public static function getMap(){

        return [
            new IntegerField('ID',[
                'primary' => true,
                'autocomplete' => true
            ]),
            (new IntegerField('GAMEMODE_ID'))->configurePrimary(true),
            (new Reference(
                'GAMEMODE',
                GameModeTable::class,
                Join::on('this.GAMEMODE_ID', 'ref.
                ID')
            ))->configureJoinType('inner'),
            (new IntegerField('DAY_NUMBER'))->configurePrimary(true),
            (new IntegerField('TIME'))->configurePrimary(true),
            (new DatetimeField('DATE'))->configurePrimary(true),
            (new IntegerField('UNIQ'))->configurePrimary(true)
        ];
    }
}

Saving the calendar itself happens like this:
foreach ($ob->shedules as $dayNumber => $arTimes){

            foreach ($arTimes as $val){

                $time = new CustomSchedule(false);

                $time->setDayNumber($dayNumber)->setTime(\Helper::getMinutesByHourseString($val));
                $time->setUniq(time());

                $gameMode->addToSchedules($time);

            }
        }

Saving should work via $gameMode->addToCustomSchedules($time) but it doesn't save.
I also tried to just get the associated "calendar" fields by GAMEMODE_ID ($gameMode->getCustomSchedules()), but still nothing is displayed.
At the same time, if you just do getList() of this table without any filter, then the "calendar" table is displayed correctly.
What could be wrong? Why is the table link not working? $gameMode->getCustomSchedules() should, in theory, select those "calendar" points that correspond to the selected $gameMode (the $gameMode variable stores the selected product, made by getList through the GameModeTable table)

The product
6127839cf07ae768945232.png

table The calendar table itself:
612783cb30442391538594.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question