How to search a INT field with Asterix?

Hello,

how is it possible to search a INT field with Asterix?

For example:

$query = $xpdo->newQuery('Box');
$query->where(array('id:like' => "%$id%"));
$query->andCondition(array('user_id:like' => "%$user_id%"));

Thank you in advance.

bye
Chris

No, it’s not possible

But what exactly are you trying to do?

If $id has (for example) a value of 7, what IDs do you expect to be in the query result?

May by my example is a little bit confusing.

Let us have an user_id (95) and we want to search for it. But you don’t know it exactly.
So we could search for 9.

You could do such a search, if you cast the id column as type CHAR.
Something like this:

<?php
$query = $modx->newQuery('modResource');
$query->where("CAST(id as CHAR(50)) LIKE '%9%'");

$output = [];
$results = $modx->getCollection('modResource', $query);
foreach($results as $result){
    $output[] = $result->get('id');
}
return implode(',', $output);
1 Like

thats it, thank you so much. :pray: