N
N
NeuroPastor2016-11-16 16:22:00
PHP
NeuroPastor, 2016-11-16 16:22:00

Passing a numeric value (int) to the snippet. How?

Good afternoon!
There is a chunk with content (wayfinder output):

and there is a snippet:

$sql = "SELECT * FROM {$modx->getTableName('modResource')} WHERE parent = $parent";
$q = $modx->prepare($sql);
$q->execute(array(0));
$arr = $q->fetchAll(PDO::FETCH_ASSOC);
echo count($arr);

The bottom line is that a string is being passed. When trying to convert (int), the $parent variable becomes equal to 0. Without conversion, it still returns 0.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
NeuroPastor, 2016-11-16
@NeuroPastor

Everyone, back off. Wayfinder gives out a kind of crooked ID. How exactly, too lazy to understand.
In general, you have to give

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question