Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Phalcon search preform


I need a advice with my search section ... Il give an example of what I need.

Il recive a GET request from my front - end (AngularJS) and it will look like this:


DB name : cars DB tables : cars, cars_locations, cars_types

I have to handle request, preform search and output all cars with that conditions with my api in JSON and send back to my front - end ..

What is the best way to preform this search ? ..



How i do it This is the short version more or less, I hope it will help you out

function getBuilder(){

    $builder = new \Phalcon\Mvc\Model\Query\Builder();

    if ($_POST['year_from'] > 0 ){
        $builder->andWhere('year > "year_from', [ 'year_from' => $_POST['year_from']; 

    //and so on and so on..... where i build my whole query


$builder = getBuilder();

$paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
    "builder" => $builder,
    "limit"=> 40,
    "page" => $pageNum


Thanks on help both...

I used named routes to handle url request and preform search based on my url parameters ...