| @@ 43-55 (lines=13) @@ | ||
| 40 | return true; |
|
| 41 | } |
|
| 42 | ||
| 43 | if (! \is_array(reset($values))) { |
|
| 44 | $values = [$values]; |
|
| 45 | } |
|
| 46 | ||
| 47 | // Here, we will sort the insert keys for every record so that each insert is |
|
| 48 | // in the same order for the record. We need to make sure this is the case |
|
| 49 | // so there are not any errors or problems when inserting these records. |
|
| 50 | else { |
|
| 51 | foreach ($values as $key => $value) { |
|
| 52 | ksort($value); |
|
| 53 | $values[$key] = $value; |
|
| 54 | } |
|
| 55 | } |
|
| 56 | // Finally, we will run this query against the database connection and return |
|
| 57 | // the results. We will need to also flatten these bindings before running |
|
| 58 | // the query so they are all in one huge, flattened array for execution. |
|
| @@ 30-42 (lines=13) @@ | ||
| 27 | // Since every insert gets treated like a batch insert, we will make sure the |
|
| 28 | // bindings are structured in a way that is convenient for building these |
|
| 29 | // inserts statements by verifying the elements are actually an array. |
|
| 30 | if (! \is_array(reset($values))) { |
|
| 31 | $values = [$values]; |
|
| 32 | } |
|
| 33 | ||
| 34 | // Since every insert gets treated like a batch insert, we will make sure the |
|
| 35 | // bindings are structured in a way that is convenient for building these |
|
| 36 | // inserts statements by verifying the elements are actually an array. |
|
| 37 | else { |
|
| 38 | foreach ($values as $key => $value) { |
|
| 39 | ksort($value); |
|
| 40 | $values[$key] = $value; |
|
| 41 | } |
|
| 42 | } |
|
| 43 | // We'll treat every insert like a batch insert so we can easily insert each |
|
| 44 | // of the records into the database consistently. This will make it much |
|
| 45 | // easier on the grammars to just handle one type of record insertion. |
|