duanpuluan0480 2014-10-23 20:13
浏览 64
已采纳

你能用模数和Propel Criteria吗?

I want to skip 'N' rows when I pull data. Using raw SQL I can accomplish this usingWHERE 'id' %%%u=0 where 'u' is my interval. Can I accomplish this using the Criteria object? I've tried this: $c->getNewCriterion(GaugeDataPeer::ID%$interval, 0, Criteria::EQUAL); but to no avail.

This is on Symfony 1.4. Not sure what Propel version.

Here's the full query I'm trying to recreate:

$query  = sprintf("SELECT *
                          FROM `processed_gauge_data`
                          WHERE `id` %%%u=0 AND `processed_gauge_data`.`gauge_id` IN (%s) AND `processed_gauge_data`.`stamp` >= '%s' AND `processed_gauge_data`.`stamp` <= '%s';",
                  $interval,
                  implode(',', $gauge),
                  mysql_real_escape_string(date('Y-m-d H:i:s', $start)),
                  mysql_real_escape_string(date('Y-m-d H:i:s', $end))
              );
  • 写回答

2条回答 默认 最新

  • duanquezhan7268 2014-11-12 18:29
    关注

    Just use ->where

    ->where('ProcessedGaugeData.Id %%%u = 0')
    

    and better use ActiveQuery: http://propelorm.org/blog/2010/08/03/refactoring-to-propel-1-5-from-peer-classes-to-query-classes.html

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用verilog实现tanh函数和softplus函数
  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含