D
D
demnagel2022-03-10 17:51:38
ORM
demnagel, 2022-03-10 17:51:38

What am I doing wrong with the collection?

Greetings colleagues, a question arose about collections - in the documentation about this in pieces, I collected examples, but when they are executed, the data in the table does not change. Please advise what I am doing wrong.

Row deletion example

$query = MyTable::getList(['filter' => ['ID' => [1, 2]]]);
$data = $query->fetchCollection();
foreach ($data as $item){
    $data->remove($item);
}
$data->save();

Bulk item creation example
$collectionClass = MyTable::getCollectionClass();
$books = $collectionClass::wakeUp([
    ['ID' => 1, 'PROP' => 'a'],
    ['ID' => 2, 'PROP' => 'b']
]);
$books->save(true);

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