Jeremy, I took your suggestion add added Location.state_id and State.id to the fields array and it still returns the same error. Good idea, unfortunately same out come.
- Jon On Tue, Nov 20, 2012 at 9:34 AM, Jeremy Burns | Class Outfit < [email protected]> wrote: > What happens if you include State.id and Location.state_id in the fields > array? > > > Jeremy Burns > Class Outfit > > http://www.classoutfit.com > > On 20 Nov 2012, at 14:46:06, jsundquist <[email protected]> wrote: > > Hello Jeremy, > > Here is my example. Note that this is all within my model. > > public function getOrder($id = null){ > if($id === null){ > return array(); > } > > $fields = array( > 'Order.id', > > 'OrderStatus.name', > 'Location.name', > 'Location.line1', > > 'Location.line2', > 'Location.city', > 'Location.postal_code', > > 'Location.contact', > 'Location.phone', > 'Order.customer_notes', > > 'Order.internal_notes', > 'Order.external_notes', > 'OrderType.name', > > 'State.abbr' > ); > > $conditions = array( > 'Order.id' => $id > ); > > return $this->find('first', array('fields' => $fields, 'conditions' > => $conditions, 'recursive' => 2)); > } > > The following is output to the view. > > *Error: *SQLSTATE[42S22]: Column not found: 1054 Unknown column 'State.abbr' > in 'field list' > > *SQL Query: *SELECT `Order`.`id`, `OrderStatus`.`name`, `Location`.`name`, > `Location`.`line1`, `Location`.`line2`, `Location`.`city`, > `Location`.`postal_code`, `Location`.`contact`, `Location`.`phone`, > `Order`.`customer_notes`, `Order`.`internal_notes`, `Order`.`external_notes`, > `OrderType`.`name`, `State`.`abbr` FROM `intranet`.`orders` AS `Order` LEFT > JOIN `intranet`.`locations` AS `Location` ON (`Order`.`location_id` = > `Location`.`id`) LEFT JOIN `intranet`.`order_statuses` AS `OrderStatus` ON > (`Order`.`order_status_id` = `OrderStatus`.`id`) LEFT JOIN > `intranet`.`order_types` AS `OrderType` ON (`Order`.`order_type_id` = > `OrderType`.`id`) LEFT JOIN `intranet`.`shipping_methods` AS `ShippingMethod` > ON (`Order`.`shipping_method_id` = `ShippingMethod`.`id`) WHERE `Order`.`id` > = 1 LIMIT 1 > > *Notice: *If you want to customize this error message, create > app/View/Errors/pdo_error.ctp > > > I would expect that it would go down one more level to do a join on > State.id = Location.state_id however that does not appear to be the case. > I do have the models set up correctly. > > On Tuesday, November 20, 2012 1:20:38 AM UTC-6, Jeremy Burns wrote: >> >> Got an example? >> >> Jeremy Burns >> Class Outfit >> >> http://www.classoutfit.com >> >> On 20 Nov 2012, at 00:44:41, jsundquist <[email protected]> wrote: >> >> I should also state that by default my application is set to recursive = >> 1 but this query I am looking to pass in recursive=2. >> >> On Monday, November 19, 2012 6:42:22 PM UTC-6, jsundquist wrote: >>> >>> Looking through both the book.cakephp.org and also api.cakephp.org for >>> 2.x they both still mention the ability to pass in recursive as a parameter >>> however when you do this for the find method it appears it is completely >>> ignored. Is this functionality missing or deprecated? I'm doing a find >>> that needs to go one extra level deeper than normal. I was hoping to just >>> pass in recursive=>1 for this single query, but so far it looks like it >>> still only returns direct ascendants. >> >> >> -- >> Like Us on FaceBook >> https://www.facebook.com/**CakePHP<https://www.facebook.com/CakePHP> >> Find us on Twitter http://twitter.com/CakePHP >> >> --- >> You received this message because you are subscribed to the Google Groups >> "CakePHP" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to cake-php+u...@** >> googlegroups.com. >> Visit this group at >> http://groups.google.com/**group/cake-php?hl=en<http://groups.google.com/group/cake-php?hl=en> >> . >> >> >> >> >> > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > > > > > -- > Like Us on FaceBook https://www.facebook.com/CakePHP > Find us on Twitter http://twitter.com/CakePHP > > --- > You received this message because you are subscribed to the Google Groups > "CakePHP" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > Visit this group at http://groups.google.com/group/cake-php?hl=en. > > > -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. Visit this group at http://groups.google.com/group/cake-php?hl=en.
