We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

SetSource with Prefix, not working with Builder / Paginator combniation

Hello,

Hello, I have a model called Address. I created a table in my db called test_address and added the setSource("test_address"); I also set the getSource() to return "test_address";

At this point, Find and FindFirst all work correctly!

I created a Builder new \Phalcon\Mvc\Model\Query\Builder();

I created a query with a model, the model has set source with a prefix. When I use ->getSql() on the builder query, the Raw SQL shows the prefix. If I run the query without paginator, everything is still fine!

HOWEVER

As soon as I add it to the paginator the "prefix" is gone, as if it is not checking the getSource...

   $paginator = new \Phalcon\Paginator\Adapter\QueryBuilder(array(
            'builder'  => $this->builder,
            'limit' => $limit,
            'page'  => $page
        ));

   $paginator->getPaginate()

I get this ERROR:

'address' doesn't exist in database when dumping meta-data

Is this a known issue?

You have to use the model class name. ie: $builder->from(Address::class);

Good luck

That is the point, everything is set properly to run in every way except the Paginator, I do use the Model names.

  $this->builder
            ->from(['a'=>'\Modules\Address\Models\Address'])
            ->columns(['a.*'])
            ->inWhere("a.ref_token",$ref_token)
            ->andWhere("a.deleted_at is null")
            ->orderBy("a.created_at  desc")
            ->limit($this->per_page)
            ->getQuery()
            ->execute();