Note that there are some explanatory texts on larger screens.

plurals
  1. PODatamapper set_join_field without update
    primarykey
    data
    text
    <p>I'm trying to save some date with a join_field basically I have an add-up function and an count-down function</p> <pre><code>if(isset($_POST['min_product'])) { foreach($_POST['min_product'] as $index =&gt; $min_product_id) { $minproduct = new Product($min_product_id); $minproduct-&gt;save($order); $minproduct-&gt;set_join_field($order, 'amount', $_POST['min_prod_amount'][$index]); $minproduct-&gt;check_last_query(); } } if(isset($_POST['product'])) { foreach($_POST['product'] as $index =&gt; $product_id) { $product = new Product($product_id); $product-&gt;save($order); $product-&gt;set_join_field($order, 'amount', $_POST['prod_amount'][$index]); $product-&gt;check_last_query(); } } $this-&gt;set_order_row($order-&gt;id); </code></pre> <p>the Query's look like this:</p> <pre><code>UPDATE `link_orders_products` SET `amount` = '-1' WHERE `product_id` = 2 AND `order_id` = 391 UPDATE `link_orders_products` SET `amount` = '5' WHERE `product_id` = 1 AND `order_id` = 391 UPDATE `link_orders_products` SET `amount` = '1' WHERE `product_id` = 2 AND `order_id` = 391 </code></pre> <p>As query i would like to have something like:</p> <pre><code>INSERT `link_orders_products` SET `amount` = '-1' WHERE `product_id` = 2 AND `order_id` = 391 INSERT `link_orders_products` SET `amount` = '5' WHERE `product_id` = 1 AND `order_id` = 391 INSERT `link_orders_products` SET `amount` = '1' WHERE `product_id` = 2 AND `order_id` = 391 </code></pre> <p>The problem is that the amount of the first query will be override by the amount of the last one. But I would like to have them all tree in to inset in my database</p> <p>My question is How do I insert the value's that are handled by the set_join_field so they don't update?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload