Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 0.61 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to get row count with a query using Propel 1.6's Custom SQL?
  2. $con = Propel::getConnection(VerbNounPeer::DATABASE_NAME);
  3. $countSql = "SELECT COUNT(*) FROM ("
  4.                ." SELECT DISTINCT ON (fk_noun_id) *"
  5.                ." FROM verb_noun"
  6.                ." ORDER BY fk_noun_id, verb_noun_vote_count DESC"
  7.                .") inner_tb";
  8. $countSqlStmt = $con->prepare($countSql);
  9. $countSqlStmt->execute();
  10.        
  11. $recordsCount = $countSqlStmt[0];
  12.        
  13. $countSqlFormatter = new PropelArrayFormatter();
  14. $countSqlRow = $countSqlFormatter->format($countSqlStmt);
  15.        
  16. $formatter->setClass('VendorNameNameBundleModelVerbNoun');