Row Reordering
Row Reordering
I have implemented row reordering, using your great blog example Row reordering.
Specifically, to get the next value, I have modified the pertinent line to:
$next = $discount->db()->sql('select coalesce(MAX(crosswalk_prices_or_purchases_to_discounts.apply_order)+1, 1) as next FROM crosswalk_prices_or_purchases_to_discounts')->fetch();
(In a nutshell, my app allows one or more discount records--which are reorderable--per price record, which is identified by price_id
.)
I am just getting over the flu and still not at my best!
Therefore, how would I modify the statement above beginning with '$next = ...' to account for the price_id?
(I believe I need to add the equivalent of "WHERE price_id = $values['crosswalk_prices_or_purchases_to_discounts']['price_id']")
How can I do that?
Answers
Wow! I guess that it's not as bad as I thought:
Nice one. You might want to use a binding if that data is submitted from the client-side though, to make sure you don't have an SQL injection issue. There is some detail on that here.
Allan