I have a function that does this:
function registerUser($firstName, $lastName, $address, $postcode, $email, $password)
{
$params = array($firstName, $lastName, $address, $postcode, $email, $password);
$result = $this->db->bind("INSERT INTO Users VALUES (?, ?, ?, ?, ?, ?)", 'ssssss', $params);
}
Which sends off to my database class, which does this:
public function bind($query, $type, $params)
{
$this->query = $query;
$stmt = $this->mysqli->prepare($this->query);
$stmt->bind_param($type, $param);
$stmt->execute;
}
The problem is this doesn't work.
What I was hoping to do, was to take the $params
list and have it list them after the $type
, so that the query would resemble:
$stmt->bind_param('ssssss', $firstName, $lastName, $address, $postcode, $email, $password);
But obviously I'm going about it the wrong way.
is there a way to make the array...transform as it were, into a list to be printed out at the bind_param
query stage?