$conditions = array('Formula.formulasId' => $id); 
                $fields = array( 
                        'materials.description', 'formula.formulasId, 
formula.materialsId, 
formula.weight'); 
                $instructions = $this->Formula->find('all', 
                array('conditions' => $conditions, 'fields' => $fields, 
                'alias' => 'formulas', 'joins' => array ( 
                        array( 
                                'table' => 'materials', 
                                'alias' => 'materials', 
                                'conditions' => 'formula.materialsId = 
materials.file', 
                                'type' => 'left', 
                                'foreignKey' => 'materials.id' 
                        ), 
                        ))); 

Em sábado, 25 de fevereiro de 2012 18h58min32s UTC-2, bbowler86 escreveu:
>
> I have written a function that joins together two fields, the query 
> that gets outputted for some reason has the ' instead of the ` 
> symbols. 
>
> The following code: 
>
>                 $conditions = array('Formula.formulasId' => $id); 
>                 $fields = array( 
>                         'materials.description', 'formula.formulasId, 
> formula.materialsId, 
> formula.weight'); 
>                 $instructions = $this->Formula->find('all', 
>                 array('conditions' => $conditions, 'fields' => $fields, 
>                 'alias' => 'formulas', 'joins' => array ( 
>                         array( 
>                                 'table' => 'materials', 
>                                 'alias' => 'materials', 
>                                 'conditions' => 
> array('formula.materialsId' => 'materials.file'), 
>                                 'type' => 'left', 
>                                 'foreignKey' => 'materials.id' 
>                         ), 
>                         ))); 
>
> outputs this as a result: 
>
> SELECT `materials`.`description`, formulas.formulasId, 
> formulas.materialsId, formulas.weight FROM `formulas` left JOIN 
> `materials` ON (`formulas`.`materialsId` = 'materials.file') WHERE 
> `formulas`.`formulasId` = 2 
>
> which nulls out the materials.description field. What I need is 
> CakePHP to output this: 
>
> SELECT `materials`.`description`, formulas.formulasId, 
> formulas.materialsId, formulas.weight FROM `formulas` AS `formulas` 
> left JOIN `materials` AS `materials` ON (`formulas`.`materialsId` = 
> materials.file) WHERE `formulas`.`formulasId` = 2; 
>
> Any help is super appreciated. 
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to