⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Select statement inside set_relation



crazycondor
  • profile picture
  • Member

Posted 04 December 2012 - 14:16 PM

Hello every body.

I have a table that stores products with the following fields.

[b]id, product_name, product_amount, product_metric[/b]

[b](e.g. 1, 'Bread', 100, 1)[/b]

and another table that holds the metrics

[b]id, metric_title, metric_abr[/b]

[b](e.g. 1, 'Kilos', 'Kg')[/b]

and i want to show in the drop down that product name, along with the remaining amount and the metric.

[b]e.g. Bread - (100 Kg. Remaining).[/b]

I was using this code


[b]$crud->set_relation('product','products','{name} - ({ammount} {(SELECT metric_abr FROM metrics WHERE id = products.metric)} Remaining)',NULL,NULL);[/b]

which worked fine until i upgraded Grocery Crud today, to the latest version.

The strange think is that the query produced from the above code works fine in phpMyAdmin.

Any ideas?

Thanks in advance.