0

According to the api (http://trac.propelorm.org/wiki/Documentation/1.6/ModelCriteria) I was searching for something like that:

$param1 = 5;
$param2 = 3;

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

equal to

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

How can I do this with propel? I only found a way to bind only 1 variable at once.

(I don't want to do a "AND" I just want to bind more than 1 variable)

From the docs, this is for binding one variable:

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

1 Answers1

0

Well I guess Propel works like Doctrine for this point, did you try :

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

Ps: the link for documentation is so old, use the new one: http://www.propelorm.org/reference/model-criteria.html

j0k
  • 22,600
  • 28
  • 79
  • 90
  • Hi j0k, I tried it, but it failed. (Fatal error: Uncaught exception 'PropelException' with message 'Cannot determine the column to bind to the parameter in clause) I couldn't also found soemthing in the api doc about binding two params.. – eav May 15 '12 at 11:11
  • In fact, the error says that you need to give a column to the where clause. Can't you give a column in the where clause? – j0k May 15 '12 at 11:18
  • I have no idea how this should work... this is my where clause: $farmers->where('ACOS(SIN(RADIANS(?))*SIN(RADIANS(latitude))+COS(RADIANS(?))*COS(RADIANS(latitude))*COS(RADIANS(longitude-?)))*6371 > ?', array($curLat, $curLat, $curLon, $settingsArea)); – eav May 15 '12 at 11:23