Use Criteria to get bind param with many models

Using Criteria in only one model worked, but the next step i had some problems.

My models: People , Client ,Phone

    class People extends \Phalcon\Mvc\Model {
        protected $name;
        public function initialize()
          $this->hasOne("id", "Client", "id_people");
    class Client extends \Phalcon\Mvc\Model {
        protected $records;

        public function initialize()
          $this->hasOne("id_people", "People", "id");

My search form have both field : name, records,phone,email ...

I try

    $query = Criteria::fromInput($this->di, "Client", $_POST);

If a user search for field name my $query->getParams(); is empty. I tried extends my model Client but doesn`t work.

How I can use Criteria to execute one search with phone and/or name?

I want avoid traditional bind params and use fromInput.

edited Sep '14
$models = Model1::query()
                ->join('Model2', ' = Model2.fk_id')

Replace Model1 and Model2 with your models in the order you want, and set the where() clause with the fields you want to use for the search.

BTW, I don't recommend you avoid bound parameters.

edited Sep '14

I understand your point, but I want use Criteria::fromInput with getParams() to create the bind parameters on where() clause avoiding do it manually


Then try to replace Model::query() with Criteria::fromInput(), cause both methods return a Criteria. Other way I don't know how.