E
E
eugene1592019-12-04 20:45:18
MODX
eugene159, 2019-12-04 20:45:18

Why does this code cause modx to freeze?

I wrote this code:

$resources = $modx->getCollection('modResource', array('template' => 4));
var_dump($resources);

When I try to open a page where this code is called, I have an endless loading.
Why?
The problem is in var_dump. If I remove it, then everything works fine.
I tried to write this code: var_dump([1,2,3]);, everything works.
Why var_dump($resources);does it freeze? How else can you output a variable in modx?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2019-12-04
@an-tar

And how many resources do you have with pattern=4?
getCollection is generally gluttonous, because it selects objects with all the giblets.
as an option, try getIterator .. or narrow the number of objects to select, or better

$q = $modx->newQuery('modResource', array('template' => 4));
$q->select('id,pagetitle');
$q->prepare();
$q->stmt->execute();
$res = $q->stmt->fetchAll(PDO::FETCH_ASSOC);
var_dump($res);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question