Hello,
This is a pretty wise question ! The answer depends of the context. Is the number of parameters variable ? Can you easily provide an array ?...
paramaters :
Pros : you know what the parameters are, pretty cool to document your code using JavaDoc comments or simply to understand it, you can read the function name and the parameter names to understand what it does and how it works
Pros : faster code execution, you don't have to carry an array (but it won't put your server on its knees)
Cons : if you need to insert a user defined by 3 fields on Monday, 5 fields on Tuesday and 15 fields on Friday... you will have to update your parameter list 🙂. Anyway you still have to implement the insert behaviour... see next
arrays :
Pros : very useful for a generic method that will add something in your DB, the matter what the parameters are, if you insert algorithm is right, you don't have to change anything
Cons : if you don't well document your code the function prototype can confused other developers, what the hell is that $data thing ? isn't my user defined by its name, password and email ?
Cons : you carry an array... no big deal. You can still use a reference so the array is not copied.
So it depends of what you want. The idea is to plan what you want to do. What are the properties that define a user ? In theo ne hand you can create your InsertUser without worrying about new properties... Adding 1 or 2 parameters is not a big deal.
In the other hand you could create a generic function, with an array to handle future improvements : first name, last name, address...
IMHO if you want to control everything, don't use arrays, unless you really need a generic function that will handle ALL your inserts : users... It depends of what your application does. It's useful for a "InsertField" function, not a "InsertUser" function. Because here you know what you're doing, you know the parameters, what defines a user...
Creating a generic function for your whole application would mean to design a framework... So stick to the good old basics and everything should work fine.
JM. Molina