Note that there are some explanatory texts on larger screens.

plurals
  1. USmorsecodemedia
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. COI used this as a starting point for the solution. I didn't want to list out every column because I wasn't sure if there will be other columns added to the table as new features are added to the project. However, I am absolutely sure the name of the auto incrementing id field will never change. So I used `Describe` and looped through the field names removing the id and then setting it to a variable. Finally changing `$this->db->query("INSERT INTO orders_products SELECT * FROM tmpTbl");` to `$this->db->query("INSERT INTO orders_products ( $columns ) SELECT $columns FROM tmpTbl");`
      singulars
    2. CO`$orderID` and `$id` are set prior to reaching this part of the code. I overlooked them when copying the code block into the question. They remain the same for this example. Yes, `op_id` is the primary key. No, `op_id` is not `op_id` = `op_id` + `$counter`. `$counter` is the last id in `order_products`+ 1. And yes, I can guarantee that no other rows are added to the original table after I make a copy of it but before I insert the temp table rows into it.
      singulars
    3. COI've used this in multiple projects. `$this->function_name();` does work. I didn't pass a variable to the function when I was writing out the answer so I guess I should have put `$this->myfunction($val);` when answering. My apologies.
      singulars
 

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