Re: How compare fields in one query from different tables

2011-07-06 Thread Quarck
I solve my problem!. It necessary to create file of model temp_detail.php with this content: class TempDetail extends AppModel { var $name = 'TempDetail'; var $useTable = *false*; } After that everything is works. Here code in the controller: $tmpModel = 'TempDetail'; $tmpTable =

Re: How compare fields in one query from different tables

2011-07-05 Thread Dominik Gajewski
And have you tried 'contain' = array('Details'), maybe it will help 2011/7/5 Quarck quarcks...@gmail.com: I tried $this-Incident-find('all', array('conditions' = array('DATE_FORMAT(Detail.comment_date, \'%Y-%m-%d\') Incident.exp_date'))); and Cake give me an error SQL Error: 1054: Unknown

Re: How compare fields in one query from different tables

2011-07-05 Thread Дмитрий Мишаров
No, it's not work. I guess I figured out how I can solve my problem. I make this sql query: CREATE TEMPORARY TABLE tmp_details( id int( 10 ) NOT NULL , comment_id int( 5 ) NOT NULL , incident_id int( 11 ) NOT NULL , PRIMARY KEY ( id ) ); INSERT INTO tmp_details SELECT Detail.id, MAX(

Re: How compare fields in one query from different tables

2011-07-05 Thread Quarck
No, it's not work. I guess I figured out how I can solve my problem. With this sql queries I select what I need: CREATE TEMPORARY TABLE tmp_details( id int( 10 ) NOT NULL , comment_id int( 5 ) NOT NULL , incident_id int( 11 ) NOT NULL , PRIMARY KEY ( id ) ); INSERT INTO tmp_details SELECT

Re: How compare fields in one query from different tables

2011-07-04 Thread Quarck
I tried $this-Incident-find('all', array('conditions' = array('DATE_FORMAT(Detail.comment_date, \'%Y-%m-%d\') Incident.exp_date'))); and Cake give me an error SQL Error: 1054: Unknown column 'Detail.comment_date' in 'where clause'. And it's absolutely correct because sql query is SELECT

How compare fields in one query from different tables

2011-06-30 Thread Quarck
[0] = Array ( [Incident] = Array ( [id] = 37 [start_date] = 2010-10-08 [exp_date] = 2010-10-14 [incoming_num] = 453-10 [incoming_date] = 2010-10-08 ) [Detail] = Array ( [0] = Array ( [id] = 98 [incident_id] = 37 [comment_id] = 1 [comment_date] = 2010-10-11 10:07:29 [notify_only] = 0 ) [1] =

Re: How compare fields in one query from different tables

2011-06-30 Thread Dominik Gajewski
Why don't you try to create next condition in your query, 'Detail.comment_date Incident.exp_date' 2011/6/30 Quarck quarcks...@gmail.com: [0] = Array ( [Incident] = Array ( [id] = 37 [start_date] = 2010-10-08 [exp_date] = 2010-10-14 [incoming_num] = 453-10 [incoming_date] = 2010-10-08 )