Answer the question
In order to leave comments, you need to log in
How to avoid incorrect data typing when working with ORM?
Hello.
When working with ORM and the query object, there is a small (more precisely, a very big) nuisance: all fields become of type string, although in essence they are described with the correct data. Example:
$select = [
'*',
'IMG_' => 'IMG',
'SECTION.ID',
];
$query = Sale\Internals\BasketTable::query()
->registerRuntimeField('SECTION', array(
'data_type' => \Bitrix\Iblock\SectionTable::class,
'reference' => [
'=this.PRODUCT.IBLOCK_SECTION_ID' => 'ref.ID'
]
))
->registerRuntimeField('IMG', [
'data_type' => \Bitrix\Main\FileTable::class,
'reference' => [
'=this.PRODUCT.PREVIEW_PICTURE' => 'ref.ID',
]
])
->setSelect($select)
->where('FUSER_ID', $this->fuser)
->where('ORDER_ID', null)
;
$rsBasketItems = $query->exec();
while($basketItem = $rsBasketItems->fetch()){
}
Answer the question
In order to leave comments, you need to log in
If you dump basketItem, then all fields will be of type string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question