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

modelsManager limit and offset problem

Hi all,

i have an sql ;

SELECT Product._like, comment_count, title, price_lower, price, image, AffiliateOffers.name, payout_yuzde, payout_nakit, payout_type, liked_users, xml_id, brand, model, AffiliateCompanies.tracking_id, Product.url FROM [Product] JOIN [AffiliateOffers] ON Product.aff_id = AffiliateOffers.af_id AND Product.offer_id = AffiliateOffers.af_offer_id JOIN [AffiliateCompanies] ON AffiliateCompanies.af_id = AffiliateOffers.af_id WHERE Product.status = 1 ORDER BY lastlike_time desc LIMIT 0 OFFSET 20

its created with

$padza = $this->modelsManager->createBuilder() ->columns(array('Product._like','comment_count','title','price_lower','price','image','AffiliateOffers.name','payout_yuzde','payout_nakit','payout_type','liked_users','xml_id','brand','model','AffiliateCompanies.tracking_id','Product.url')) ->from('Product') ->join('AffiliateOffers','Product.aff_id = AffiliateOffers.af_id AND Product.offer_id = AffiliateOffers.af_offer_id') ->join('AffiliateCompanies','AffiliateCompanies.af_id = AffiliateOffers.af_id') ->where('Product.status = 1') ->limit(0,20) ->orderBy('lastlike_time desc') ->getPhql();

That code

its working okey, but i edited sql , edited limit and offset

$new_sql = ' SELECT Product._like, comment_count, title, price_lower, price, image, AffiliateOffers.name, payout_yuzde, payout_nakit, payout_type, liked_users, xml_id, brand, model, AffiliateCompanies.tracking_id, Product.url FROM [Product] JOIN [AffiliateOffers] ON Product.aff_id = AffiliateOffers.af_id AND Product.offer_id = AffiliateOffers.af_offer_id JOIN [AffiliateCompanies] ON AffiliateCompanies.af_id = AffiliateOffers.af_id WHERE Product.status = 1 ORDER BY lastlike_time desc';

$new_sql .= ' LIMIT :limit OFFSET :offset';

$products = $this->modelsManager->executeQuery($new_sql,array('limit'=>21, 'offset' => 20));

products working and get products but no limit? all products its fetching

Thanks for all



39.3k

and now i find that , after i get phql i couldnt work it with executeQuery()

how can i solve that ?

I met such a problem (compiled phalcon on ubuntu), decided install from repository.