We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Problem with Criteria::fromInput - BUG ?

I use the following code:

$query = Criteria::fromInput($this->di, 'Objects', $array);
$this->persistent->searchParams = $query->getParams();

if ($this->persistent->searchParams) {
    $parameters = $this->persistent->searchParams;

$objects = Objects::find($parameters);

The problem is, when I have only one value in $array (Array ( [country_id] => HR )) , I get ''Undefined variable ""parameters"" error.

When I have multiple values, it works fine.

Is this a bug or is it supposed to work like this?


To avoid that error you can change it to:

$query = Criteria::fromInput($this->di, 'Objects', $array);

$objects = Objects::find($query->getParams());


This is not solving the problem.

If $array has only one parameter, $query->getParams() returns nothing.

If it has more that one, it's ok..

It does seem to me like a bug, this is my full searchAction code: https://pastebin.com/4psXDHSr


Ok, i found my error... I should have used cc_fips instead of country_id