推进创建查询中的多个变量

时间:2012-05-14 15:51:08

标签: php mysql propel

根据apihttp://trac.propelorm.org/wiki/Documentation/1.6/ModelCriteria)我正在寻找类似的东西:

$param1 = 5;
$param2 = 3;

select id, name from testtable where ((sin(?) * (cos(?));

等于

select id, name from testtable where ((sin($param1) * (cos($param2));

我怎么能用推进来做到这一点?我只找到了一次只绑定1个变量的方法。

(我不想做“AND”我只想绑定更多而不是1个变量)

从文档中,这是绑定一个变量:

<?php
// Finding all Books where title = 'War And Peace'
$books = BookQuery::create()
  ->where('Book.Title = ?', 'War And Peace')
  ->find();
?>

1 个答案:

答案 0 :(得分:0)

嗯,我觉得Propel在这一点上像Doctrine一样,你试过了吗?

$res = TestQuery::create()
  ->where('((sin(?) * (cos(?))', array($param1, $param2))
  ->find();

Ps:文档的链接太旧了,请使用新的:http://www.propelorm.org/reference/model-criteria.html