Zurmo Cron Job Configuration - zurmocrm

Is there any good CRON configuration for Zurmo. The documentation seems less and forum are not much active. Zurmo was hosted in Google Compute VM using Bitnami. So it was installed in
/opt/bitnami/apps/zurmo/

*/5 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user Monitor &> /dev/null
30 4 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user CurrencyRatesUpdate &> /dev/null
30 2 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ImportCleanup &> /dev/null
*/30 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user AddressGeocodeUpdate &> /dev/null
0 */1 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user AutoresponderQueueMessagesInOutbox &> /dev/null
0 */1 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user CampaignGenerateDueCampaignItems &> /dev/null
0 */1 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user CampaignMarkCompleted &> /dev/null
0 */1 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user CampaignQueueMessagesInOutbox &> /dev/null
0 22 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ClearSentNotificationsEmail &> /dev/null
*/5 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user EmailArchiving &> /dev/null
*/5 * * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user EmailBounce &> /dev/null
*/1 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ProcessOutboundEmail &> /dev/null
0 22 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user TestOutboundEmail &> /dev/null
5 18 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user DraftEmailTemplateCleanup &> /dev/null
5 18 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ExportCleanup &> /dev/null
5 18 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user CheckZurmoUpdates &> /dev/null
0 * */1 * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user JobLogCleanup &> /dev/null
0 */1 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user UpdateModelsLatestActivityDateTimeByMeeting &> /dev/null
*/15 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ByTimeWorkflowInQueue &> /dev/null
*/15 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user WorkflowMessageInQueue &> /dev/null
0 22 * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user WorkflowValidityCheck &> /dev/null
*/10 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ReadPermissionSubscriptionUpdate &> /dev/null
5 18 * * 6 cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user ShortUrlCleanup &> /dev/null
*/5 * * * * cd /opt/bitnami/apps/zurmo/htdocs/app/protected/commands && ./zurmoc jobManager user SendGridEmailEvents &> /dev/null

Related

Rails: mysql error unknown column in sub query

I am implementing a search filter in my web app. using sub-queries like this:
tool = Tool.select('*, (select ROUND(AVG(ratings.rating)) from ratings where tool_id = tools.id AND rating_type = 2) as ratings,
3956 * 2 * ASIN(SQRT(POWER(SIN(('+"#{params[:latitude]}"+' - abs(tools.latitude)) * pi()/180 / 2), 2) + COS('+"#{params[:latitude]}"+' * pi()/180 ) * COS(abs(tools.latitude) * pi()/180) * POWER(SIN(('+"#{params[:longtude]}"+' - abs(tools.longitude)) * pi()/180 / 2), 2) )) as distance').where('user_id != ? AND pause_status =?', user_id, 0).order('distance asc')
# =>delivery type only if delivery type is 1
if params[:search].present? && !params[:search].nil?
tool = tool.where('title LIKE ? OR description LIKE ?', "%#{params[:search]}%","%#{params[:search]}%")
end
# =>Category search
if params[:category_id].present? && !params[:category_id].nil?
tool = tool.where('category_id =?', params[:category_id])
end
# =>price range
if params[:max_price].present? && params[:min_price].present? && !params[:max_price].nil? && !params[:min_price].nil?
tool = tool.where('price >= ? AND price <= ?', params[:min_price].to_f, params[:max_price].to_f)
end
# => filter availability
if params[:availability].present? && !params[:availability].nil?
if params[:availability].to_i == 2
tool = tool.where('available_type =?', 2) #=> weekend
elsif params[:availability].to_i == 1
tool = tool.where('available_type =?', 1) # => weekdays
end
end
if params[:rating].present? && !params[:rating].nil?
tool = tool.having('ratings > 5')
end
if params[:delivery_type].present? && !params[:delivery_type].nil?
if params[:delivery_type].to_i == 0
tool = tool.where('delivery_type = ?', 0)
end
end
if tool.empty?
return []
else
tool_array = []
tool.each do |t|
tool_hash = {}
tool_hash['id'] = t.id
tool_hash['title'] = t.title
tool_hash['latitude'] = t.latitude
tool_hash['longitude'] = t.longitude
tool_hash['attachment'] = Image.get_single_attachment(t.id)
tool_array.push(tool_hash)
end
return tool_array
end
when I pass rating parameter it print the query like this:
SELECT COUNT(*) FROM `tools` WHERE (user_id != 3 AND pause_status =0) HAVING (ratings > 5)"
and without rating parameter:
SELECT *, (select ROUND(AVG(ratings.rating)) from ratings where tool_id = tools.id AND rating_type = 2) as ratings, 3956 * 2 * ASIN(SQRT(POWER(SIN((30.657797735213 - abs(tools.latitude)) * pi()/180 / 2), 2) + COS(30.657797735213 * pi()/180 ) * COS(abs(tools.latitude) * pi()/180) * POWER(SIN((76.7327738833397 - abs(tools.longitude)) * pi()/180 / 2), 2) )) as distance FROM `tools` WHERE (user_id != 3 AND pause_status =0) ORDER BY distance asc"
and I a error like this in my having clause:
"error": "Mysql2::Error: Unknown column 'ratings' in 'having clause': SELECT COUNT(*) FROM `tools` WHERE (user_id != 3 AND pause_status =0) HAVING (ratings > 5)",
"code": 301
and if I comment the each loop it works.
Please tell where I am doing wrong.
having should work with group by
You can't use alias name as ratings in the following line,
select ROUND(AVG(ratings.rating)) from ratings where tool_id = tools.id AND rating_type = 2) as ratings
Give a different name as MYSQL confusing ratings as column.

mysql matching multiple and's and or's

I am trying to get rows from a table where there are matches on multiple other tables.
This is the query I am running.
SELECT qt.*, DATEDIFF(CURRENT_DATE, STR_TO_DATE(up.DOB, '%m-%d-%Y')) / 365 AS Age
FROM UserProfile AS up, Game AS g, QuestionTable AS qt
WHERE NOT EXISTS(SELECT * FROM Options WHERE UserID = 75 AND QID = qt.QID AND DateTime >= CURDATE())
AND g.Active = 1 AND g.QID = qt.QID
AND (((g.Gender = up.Gender OR g.Gender = 'B') AND ((g.City = up.City AND g.Zip = up.Zip AND g.Country = up.Country) OR g.Home = 0) AND ((Age BETWEEN g.Maximum AND g.Minimum) OR g.Age = 0) AND ((SQRT( POW( 69.1 * ( g.Latitude - -93.5746359 ) , 2 ) + POW( 69.1 * ( 44.9737707 - g.Longitude ) * COS( g.Latitude / 57.3 ) , 2 ) ) > g.Distance) OR g.Geo = 0)) OR g.Special = 0)
GROUP BY qt.QID
I have ran this expression through C# and it returns true, yet it is only matching on the 'g.Special = 0' part through MySql.
Any help on this would be much appreciated!
Resolved the issue by fixing some mistakes I made and changed the query to this,
SELECT *
FROM QuestionTable AS qt
WHERE NOT EXISTS
(SELECT * FROM Options WHERE UserID = 75 AND QID = qt.QID AND DateTime >= CURDATE())
AND EXISTS(SELECT g.* FROM UserProfile AS up, Game AS g WHERE g.Active = 1 AND g.QID = qt.QID AND(g.Special = 0 OR(
(g.Gender = up.Gender OR g.Gender = 'B') AND
((g.City = up.City AND g.zip = up.Zip AND g.Country = up.Country) OR g.Home = 0) AND
((SQRT( POW( 69.1 * ( g.Latitude - 44.9737707 ) , 2 ) + POW( 69.1 * ( -93.5746359 - g.Longitude ) * COS( g.Latitude / 57.3 ) , 2 ) ) < g.Distance) OR g.Geo = 0) AND
((DATEDIFF(CURRENT_DATE, STR_TO_DATE(DOB, '%m/%d/%Y'))/365.25 BETWEEN g.Minimum AND g.Maximum) OR g.Age = 0))))

Query mysql for post and comments system

I'm using codeigniter for make a post and comments system. I did all the querys but I don't know how get the comments in the table post_comment. This is my query for take all the post shared. Thank you for the help.
function get_post_profile($user_id,$limit) {
$this->db->select('post_user.user_id,post_user.id_post_shared,post_shared.post_text,users.name,users.surname,users.id');
$this->db->join('post_shared', 'post_shared.id_post = post_user.id_post_shared');
$this->db->join('users','users.id = post_user.user_id');
$this->db->where('post_user.user_id',$user_id);
$this->db->order_by('post_user.id_post_shared','DESC');
$this->db->limit($limit);
$query = $this->db->get('post_user');
if ($query->num_rows() > 0) {
return $query->result();
} else {
return false;
}
}
users_table
id | name | surname |
1 jhon Smith
2 Sally Dunk
post_user table
id_post_shared | user_id |
1 1
post_share table
id_post | post_text
1 Hello guys
post_comment table
comment_text | id_post | id_user
Hello! 1 2
Try and reply:
$this->select('post_comment.comment_text, post_comment.id_post, post_comment.id_user')->join('post_share', 'post_share.id_post = post_comment.id_post')->join('users', 'users.id = post_comment.id_user')->get('post_comment');
EDIT
function get_comments(){
$data = array();
$posts = array();
$posts = $this->db->select('id_post as post_id, post_text', false)->order_by('id_post', 'desc')->get('post_share', 10)->result_array(); #get first 10 posts
if( is_array( $posts ) && count( $posts ) > 0 ){
foreach( $posts as $key=>$each ){
## gather the comments for the posts ###
$comments = array();
$comments = $this->db->select('comment_text, id_user')->where('id_post', $each['post_id'])->get('post_comment')->result_array();
if( is_array( $comments ) && count( $comments ) ){
$posts[$key]['comments'] = $comments;
}
}
}
return $posts;
}
EDIT 1
if( isset( $posts ) && is_array( $posts ) && count( $posts ) > 0 ){
foreach( $posts as $key=>$each ){
echo "Post id :".$each['post_id']." Post txt: ".$each['post_text']."<br>";
if( isset( $each['comments'] ) && is_array( $each['comments'] ) && count( $each['comments'] ) ){
foreach( $each['comments'] as $subKey=>$subEach ){
echo "Comment Txt :".$subEach['comment_text']."<br>";
}
}
}
}
Add LEFT JOIN to your post_comment
$this->db->select('post_user.user_id,post_user.id_post_shared,
post_shared.post_text,users.name,users.surname,users.id,post_comment.comment_text');
$this->db->join('post_shared', 'post_shared.id_post = post_user.id_post_shared');
$this->db->join('users','users.id = post_user.user_id');
$this->db->join('post_comment ','users.id = post_comment .id_user','LEFT');
$this->db->where('post_user.user_id',$user_id);
$this->db->order_by('post_user.id_post_shared','DESC');
$this->db->limit($limit);
$query = $this->db->get('post_user');
third parameter in the call is to specify the type of join join('table','relation','join type')
Try this:
$sql = "SELECT a.*,b.id,b.name,b.surname,c.id_post_shared,c.user_id,d.id_post,d.post_text
FROM post_comment a, users_table b, post_user c,post_share d
WHERE b.id = c.user_id
AND b.id = $user_id
AND c.id_post_shared = d.id_post
AND d.id_post = a.id_post";
$result = $this->db->query($sql)->result_array();
echo $result[0]['comment_text'];

Data is missing from Query

I have this query to combine dates in a date field of sales.
Once the person has more then 3 purchase dates and we run the query, they do not show up at all. If they have two or three it's not a problem, as soon as the have four dates to combine it just skips the line all together.
<?php
set_time_limit(0);
$server = 'localhost';
$login = 'xxxx';
$password = 'xxxx';
$db = 'xxx';
$table = 'xxx';
$filename = '/fakepath/file.csv';
mysql_connect($server, $login, $password);
mysql_select_db($db);
$fp = fopen($filename, "w");
$query = 'SET GLOBAL group_concat_max_len=15000';
mysql_query($query);
$res = mysql_query("SELECT t1.employee_number, t1.first_name, t1.last_name
, GROUP_CONCAT( DATE_FORMAT( t1.dates_of_purchase, '%m-%d-%y' ) SEPARATOR ' & ' ) AS Purchase_Date
, t1.Dept, t1.Location
FROM XXX AS t1
LEFT JOIN XXX AS t2 ON ( t1.employee_number = t2.employee_number
AND t1.last_name = t2.last_name
AND t1.QTY != t2.QTY )
WHERE t1.dates_of_purchase >= '2011-01-01'
AND t1.QTY >=1
AND t2.employee_number IS NULL
GROUP BY t1.employee_number, t1.first_name, t1.last_name
ORDER BY t1.employee_number
");
mysql_data_seek($res, 0);
while($row = mysql_fetch_assoc($res)) {
$line = "";
$comma = "xxx,";
foreach($row as $value) {
$line .= $comma . '' . str_replace('', '', $value) . '';
$comma = ",";
}
$line .= "\n";
fputs($fp, $line);
}
fclose($fp);`
This is the code and it works for the most part.
Why does it not return any rows for more then 3 purchase dates?
Here is the data:
Account employee_number first_name last_name dates_of_purchase Dept Location QTY Vendor id
ONTH30 652526 G HARRIPERSAD 2011-02-16 PWU NUCLEAR SUPPLY CHAIN 1 MSS 1836
ONTH30 652561 AJJ FELS 2011-09-15 PWU NOSS 1 MSS 4319
ONTH30 652561 AJJ FELS 2011-06-23 PWU NOSS 1 MSS 8898
ONTH30 652561 AJJ FELS 2011-08-18 PWU NOSS 1 MSS 8938
ONTH30 652526 G HARRIPERSAD 2011-11-16 PWU PICKERING 1 MSS 7231
ONTH30 652561 AJJ FELS 2011-12-08 PWU NOSS -1 MSS 8141
ONTH30 652561 AJJ FELS 2011-10-13 PWU NOSS 1 MSS 9055
The data missing from the output is employee number 652561.
It does not get output to the CSV file it's skips it all together for some reason.
The output should look like this:
opg, 652561, AJJ, FELS, 10-13-2011 & 12-08-2011 & 08-18-2011 & 06-23-2011 & 09-15-2011 , ESR, PICKERING A

Subqueries in Doctrine for Having field

I am dealing with several bus routes.
I want to fetch the two points closest to my departure and destination points.
So what I do is :
$q = Doctrine_query::create()
->select('r.*')
//d1 and d2 are the distance between the p1 and p2 points and my dest and depa points.
->addSelect("(6371 * ACOS(SIN(RADIANS($depa_lat)) * SIN(RADIANS(p1.lat)) + COS(RADIANS($depa_lat)) * COS(RADIANS(p1.lat)) * COS(RADIANS(p1.lng) - RADIANS($depa_lng)))) d1")
->addSelect("(6371 * ACOS(SIN(RADIANS($dest_lat)) * SIN(RADIANS(p2.lat)) + COS(RADIANS($dest_lat)) * COS(RADIANS(p2.lat)) * COS(RADIANS(p2.lng) - RADIANS($dest_lng)))) d2")
->from('Route r')
->innerJoin('r.Points p1')
->innerJoin('r.Points p2')
//this is just to select only the points close enough to my depa and dest point
->andWhere('p1.lat >= ?',$depa_lat - $eps_lat)
->andWhere('p1.lat <= ?',$depa_lat + $eps_lat)
->andWhere('p1.lng >= ?',$depa_lng - $eps_lng)
->andWhere('p1.lng <= ?',$depa_lng + $eps_lng)
->andWhere('p2.lat >= ?',$dest_lat - $eps_lat)
->andWhere('p2.lat <= ?',$dest_lat + $eps_lat)
->andWhere('p2.lng >= ?',$dest_lng - $eps_lng)
->andWhere('p2.lng <= ?',$dest_lng + $eps_lng)
//those subqueries are to fetch the two closest points, and they seem to be the cause of the crash
->having('d1 =
(
SELECT MIN((6371 * ACOS(SIN(RADIANS('.$depa_lat.')) * SIN(RADIANS(p3.lat)) + COS(RADIANS('.$depa_lat.')) * COS(RADIANS(p3.lat)) * COS(RADIANS(p3.lng) - RADIANS('.$depa_lng.')))))
FROM Point p3
WHERE p3.lat >= '.$depa_lat - $eps_lat.' AND p3.lat <= '.$depa_lat + $eps_lat.' AND p3.lng >= '.$depa_lng - $eps_lng.' AND p3.lng <= '.$depa_lng + $eps_lng.' AND p3.route_id = p1.route_id
)')
->having('d2 =
(
SELECT MIN((6371 * ACOS(SIN(RADIANS('.$dest_lat.')) * SIN(RADIANS(p4.lat)) + COS(RADIANS('.$dest_lat.')) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS('.$dest_lng.')))))
FROM Point p4
WHERE p4.lat >= '.$dest_lat - $eps_lat.' AND p4.lat <= '.$dest_lat + $eps_lat.' AND p4.lng >= '.$dest_lng - $eps_lng.' AND p4.lng <= '.$dest_lng + $eps_lng.' AND p4.route_id = p2.route_id
)')
->orderBy('d1+d2')
->execute();
The error is :
Doctrine_Exception
Couldn't find class p4
Is there a better way to do this ? I thought that MIN should go with GROUP BY, and I tried GROUP BY p3.id and GROUP BY p4.id, but that didn't change.
For those it could help, here's the stack trace from Symfony :
It's weird that the parseAggregateFunction() function erases the query, isn't it ?
at Doctrine_Table->initDefinition()
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Table.php line 256 ...
at Doctrine_Table->__construct('-58', object('Doctrine_Connection_Mysql'), 1)
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php line 1126 ...
at Doctrine_Connection->getTable('-58')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query.php line 1942 ...
at Doctrine_Query->loadRoot('-58', '-58')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query.php line 1740 ...
at Doctrine_Query->load('-58', )
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 89 ...
at Doctrine_Query_Having->_parseAliases('-58.3819582))))) FRO')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 70 ...
at Doctrine_Query_Having->parseAggregateFunction('-58.3819582))))) FRO')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('p4.lng) - RADIANS(-58.3819582))))) FROM')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM P')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Po')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Poi')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Poin')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 W')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WH')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHE')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHER')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('(6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 63 ...
at Doctrine_Query_Having->parseAggregateFunction('SELECT MIN((6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE 0')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Having.php line 118 ...
at Doctrine_Query_Having->load('d2 = SELECT MIN((6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE 0')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Condition.php line 92 ...
at Doctrine_Query_Condition->parse('d2 = SELECT MIN((6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE 0')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Condition.php line 80 ...
at Doctrine_Query_Condition->parse('d2 = SELECT MIN((6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE 0 AND p4.route_id = p2.route_id')
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php line 2077 ...
at Doctrine_Query_Abstract->_processDqlQueryPart('having', array('d2 = SELECT MIN((6371 * ACOS(SIN(RADIANS(-58.3819582)) * SIN(RADIANS(p4.lat)) + COS(RADIANS(-58.3819582)) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS(-58.3819582))))) FROM Point p4 WHERE 0 AND p4.route_id = p2.route_id'))
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query.php line 1167 ...
at Doctrine_Query->buildSqlQuery(1)
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query.php line 1133 ...
at Doctrine_Query->getSqlQuery(array())
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php line 958 ...
at Doctrine_Query_Abstract->_execute(array())
in SF_SYMFONY_LIB_DIR/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Query/Abstract.php line 1026 ...
at Doctrine_Query_Abstract->execute()
in SF_ROOT_DIR/lib/model/doctrine/LineTable.class.php line 58 ...
at LineTable->findLinesFromLatLngToLatLng('-34.5835397', '-58.4246329', '-58.3819582', '-58.3819582', 0.4)
in SF_ROOT_DIR/apps/frontend/modules/map/actions/actions.class.php line 57 ...
at mapActions->executeSearch(object('sfWebRequest'))
in SF_SYMFONY_LIB_DIR/action/sfActions.class.php line 60 ...
at sfActions->execute(object('sfWebRequest'))
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 92 ...
at sfExecutionFilter->executeAction(object('mapActions'))
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 78 ...
at sfExecutionFilter->handleAction(object('sfFilterChain'), object('mapActions'))
in SF_SYMFONY_LIB_DIR/filter/sfExecutionFilter.class.php line 42 ...
at sfExecutionFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR/filter/sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR/filter/sfRenderingFilter.class.php line 33 ...
at sfRenderingFilter->execute(object('sfFilterChain'))
in SF_SYMFONY_LIB_DIR/filter/sfFilterChain.class.php line 53 ...
at sfFilterChain->execute()
in SF_SYMFONY_LIB_DIR/controller/sfController.class.php line 238 ...
at sfController->forward('map', 'search')
in SF_SYMFONY_LIB_DIR/controller/sfFrontWebController.class.php line 48 ...
at sfFrontWebController->dispatch()
in SF_SYMFONY_LIB_DIR/util/sfContext.class.php line 170 ...
at sfContext->dispatch()
in SF_ROOT_DIR/web/frontend_dev.php line 13 ...
You might try something like this:
$q = Doctrine_Query::create()
->select('r.*')
->addSelect("(6371 * ACOS(SIN(RADIANS($depa_lat)) * SIN(RADIANS(p1.lat)) + COS(RADIANS($depa_lat)) * COS(RADIANS(p1.lat)) * COS(RADIANS(p1.lng) - RADIANS($depa_lng)))) d1")
->addSelect("(6371 * ACOS(SIN(RADIANS($dest_lat)) * SIN(RADIANS(p2.lat)) + COS(RADIANS($dest_lat)) * COS(RADIANS(p2.lat)) * COS(RADIANS(p2.lng) - RADIANS($dest_lng)))) d2")
->from('Route r')
->innerJoin('r.Points p1')
->innerJoin('r.Points p2')
->andWhere('p1.lat >= ?',$depa_lat - $eps_lat)
->andWhere('p1.lat <= ?',$depa_lat + $eps_lat)
->andWhere('p1.lng >= ?',$depa_lng - $eps_lng)
->andWhere('p1.lng <= ?',$depa_lng + $eps_lng)
->andWhere('p2.lat >= ?',$dest_lat - $eps_lat)
->andWhere('p2.lat <= ?',$dest_lat + $eps_lat)
->andWhere('p2.lng >= ?',$dest_lng - $eps_lng)
->andWhere('p2.lng <= ?',$dest_lng + $eps_lng);
$d1 = $q->createSubquery()
->select('MIN((6371 * ACOS(SIN(RADIANS('.$depa_lat.')) * SIN(RADIANS(p3.lat)) + COS(RADIANS('.$depa_lat.')) * COS(RADIANS(p3.lat)) * COS(RADIANS(p3.lng) - RADIANS('.$depa_lng.')))))')
->from('Point p3')
->where('WHERE p3.lat >= '.$depa_lat - $eps_lat.' AND p3.lat <= '.$depa_lat + $eps_lat.' AND p3.lng >= '.$depa_lng - $eps_lng.' AND p3.lng <= '.$depa_lng + $eps_lng.' AND p3.route_id = p1.route_id');
$d2 = $q->createSubquery()
->select('MIN((6371 * ACOS(SIN(RADIANS('.$dest_lat.')) * SIN(RADIANS(p4.lat)) + COS(RADIANS('.$dest_lat.')) * COS(RADIANS(p4.lat)) * COS(RADIANS(p4.lng) - RADIANS('.$dest_lng.')))))')
->from('Point p4')
->where('p4.lat >= '.$dest_lat - $eps_lat.' AND p4.lat <= '.$dest_lat + $eps_lat.' AND p4.lng >= '.$dest_lng - $eps_lng.' AND p4.lng <= '.$dest_lng + $eps_lng.' AND p4.route_id = p2.route_id');
$q->having('d1 = (' . $d1->getDql() . ')')
->having('d2 = (' . $d2->getDql() . ')')
->orderBy('d1+d2')
->execute();