Hello.

i have a simple app running 2 models

Order hasMany Item
Item belongsTo Order

the "code" field in in both models but in ItemModel this is a virtual
field

var $virtualFields = array("code" => "CONCAT(Order.code, '-',
Item.n)");

here's the problem:

$myItem = $this->Item->find("all", array(
   "conditions" => array(
      "n" => $n,
      "Order.code" => $orderCode
   ),
   "fields" => "id"
));

returns this SQL

SELECT `Item`.`id` FROM `items` AS `Item` LEFT JOIN `orders` AS
`Order` ON (`Item`.`order_id` = `Order`.`id`) LEFT JOIN `orders` AS
`Order` ON (`Item`.`order_id` = `Order`.`id`) WHERE `n` = '002' AND
CONCAT(Order.code, '-', Item.n) = 'ORDERCODE'

the Item code overwrites Order code


Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to