Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Propel 1.2 PropePager Issue #1093

Open
n00ybfied opened this issue Jun 17, 2022 · 0 comments
Open

Propel 1.2 PropePager Issue #1093

n00ybfied opened this issue Jun 17, 2022 · 0 comments

Comments

@n00ybfied
Copy link

A question for the Propel veterans here, since it's a very old version:

I have an issue with the Propel Pager and a having clause. The Criteria is:

$c = new Criteria();
$criterion = $c->getNewCriterion(EfEventsPeer::EF_STAMMDATEN_ID, $stamm_id);
$criterion->addAnd($c->getNewCriterion(EfEventsPeer::GELOESCHT, 1, Criteria::NOT_EQUAL));
$criterion->addAnd($c->getNewCriterion(EfEventDatenPeer::ID, null, Criteria::ISNOTNULL));
$criterion->addAnd($c->getNewCriterion(EfEventsPeer::IMPORTIERT, 1, Criteria::NOT_EQUAL));    
$c->addJoin(EfEventDatenPeer::EF_EVENTS_ID, EfEventsPeer::ID, Criteria::LEFT_JOIN);
$c->addGroupByColumn(EfEventsPeer::ID);
$c->addHaving($c->getNewCriterion(EfEventDatenPeer::DATUM,  "MAX(".EfEventDatenPeer::DATUM.") < '" . date('Y-m-d') . "'", Criteria::CUSTOM));
$c->add($criterion);
$c->addDescendingOrderByColumn(EfEventsPeer::GESPERRT);
$c->addDescendingOrderByColumn(EfEventsPeer::EINGESTELLT_AM);
$c->setDistinct();

The generated SQL Code works fine in phpmyadmin. I get the expected result (around 200 entries).

SELECT DISTINCT FROM ef_events WHERE ((ef_events.EF_STAMMDATEN_ID=? AND ef_events.GELOESCHT<>?) AND ef_events.IMPORTIERT<>?) ORDER BY ef_events.GESPERRT DESC,ef_events.EINGESTELLT_AM DESC
I also get the correct result with my usual doSelect statement:

$results = EfEventsPeer::doSelect($c);
However, if I try to get the same results using the PropelPager, I always get a totalRecordCount of 1 and 1 page.

$pager = new PropelPager($c, 'EfEventsPeer', 'doSelect', 1, 10);
$pager->getTotalRecordCount();  //returns 1
$pager->getTotalPages(); //returns 1

Strangely, I do get the number of hitsPerPage (in this case 10) in my result if available. When I loop through

foreach($pager->getResult() as $single_event){
  ...
}

Im sure the issue must be a wrong addHaving criterion, but I can't solve it myself.

Any ideas? Thx a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant