I am changing an existing data storage php code from `mysql_*` functions to PDO as well changing it from Procedural to OOB programming. I was updating the SQL statements when I noticed something, fairly far into the rewriting process.

I am setting up an array for multiple tables `INSERT` and `UPDATE` queries, as I was defining an array to work as the binding values I noticed that the *order* in which the bound values are called would be different from the `UPDATE` to the `INSERT`, here is a brief example:

```
$bound_values = array(
    ':column_aa' => 'aa',
    ':column_ab' => 'ab',
    ':column_ac' => 'ac'
    )
);

```

Example sql for `INSERT`:

```
INSERT INTO `table_a` 
    (`id`, `column_aa`, `column_ab`, `column_ac`) 
VALUES 
    ('', :column_aa, :column_ab, :column_ac);

```

and the `UPDATE`:

```
UPDATE `table_a` SET 
    `column_ab` = :column_ab, `column_ac` = :column_ac, `column_aa` = :column_aa;

```

Example PHP PDO:

```
$pdo = new PDO('mysql:host=localhost;dbname=example', 'root', '');
// The second parameter of the PDO cursor is what I saw that raised the flag
$sth = $pdo->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute($boud_values);

```

So my question is, can I keep going forward using this method without an issue as to what order the SQL statements are in vs the `$bound_values` array, or am I right in being concerned and need to make some changes?

Please note that the existing code I am working with isn't anywhere **near** as simple as the SQL statements I have shown above.
['https://Stackoverflow.com/questions/16865303', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2200704/']
Using named placeholders (:col\_name), you can put them in any order as you please. However, using positional placeholders (?) - you need to put them in order.
It doesn't matter as long as you use named parameters ( `:somename` ). The binding simply tells your database engine "where I wrote the placeholder `:abc`, fill with this value. Where I wrote placeholder `:xyz`, put this other value".

Think about how the code would look like if you were binding each value separately instead of all at once in the execute

```
$sth->bindParam(':abc', 'value1', PDO::PARAM_STR);
$sth->bindParam(':xyz', 'value2', PDO::PARAM_STR);
$sth->execute();

```

Switching the bindParam() order would not have any impact.

Also, note that the order in which the column are set in INSERT and UPDATE sql queries doesn't matter, so if this really bugs you (or if you like things to be standardized a little) you can just order the column the same way in both queries.

```
UPDATE table SET col2 = 'xyz', col1 = 'abc'
// is the same as
UPDATE table SET col1 = 'abc', col2 = 'xyz'

```