Bound parameters in QueryBuilder


Consider something like this:

                ->andWhere('>:id:',array('id' => $id));           

                ->columns(array('COUNT(DISTINCT AS totals'))
                ->execute(array('languagekey' => $this->languagekey(), 'id' => $id);

In here I use parameter languagekey twice, adding it in execute I have to bound a value only one time. It's for me much easier than passing the same parameter & value agan and again in the query construction

Now I use a Paginator using the QueryBuilder, something like

            $paginator=new QueryBuilder(
                    "builder" => $builder,
                    "limit" => 10,
                    "page" => $page

My question: How can I passing parameters in query execution in QueryBuilder?

Hi @omnispex you can't do that but you can make your own paginator adapter when you can set parameters like this

class MyPaginator extends \Phalcon\Paginator\Adapter\QueryBuilder {

    private $params = [];
    public function __construct(array $config) {
        private $params = $config['params'] ?? [];


    public function getPaginate() {
        if ($this->params) {

        return parent::getPaginate();

Good luck

PDO extension and db engines when not emulating prepares requries diffrent names and doesn't allow tu use same parameter in binding more than once. To enable it use:


In options of db adapter. Keep in mind it's not a good idea and this should be defintely false, beacause it's faster when database engine is doing binding.

Thank you for your reply, In short you would recommend something like?

            ->where('Articles.languagekey=:languagekey:',array('languagekey' => $this->languagekey()))
            ->andWhere('Categories.languagekey=:languagekey:',array('languagekey' => $this->languagekey()))
            ->andWhere('Categories.trash=:trash:',array('trash' =>$this->trash()));

This is what I have in an older app and it works fine with paginator, but less easier to maintain with many duplicate parameters.