I use Prepared Statements mostly to prevent SQL injections. Now I also need to filter a ENUM
type. But how should I use it in my prepared statements to maintain security?
I have a table of addresses and need to filter on the user's invoice addresses. How do I do that and keep the security? Or does it not matter?
Two options I can think of. "Invoice" in the array as a string.
public function getCustomerInvoiceAddresses($customerNumber)
{
$query = 'SELECT contactPerson, company, street, zipCode, city, deliveryMethod
FROM address
where FK_customerNumber = ?
AND addressType = ?';
$paramType = 'is';
$paramValue = array(
$customerNumber,
"Invoice"
);
$invoiceAddressArray = $this->ds->select($query, $paramType, $paramValue);
return $invoiceAddressArray;
}
Invoice in the SELECT
public function getCustomerInvoiceAddresses($customerNumber)
{
$query = 'SELECT contactPerson, company, street, zipCode, city, deliveryMethod
FROM address
where FK_customerNumber = ?
AND addressType = "Invoice"';
$paramType = 'is';
$paramValue = array(
$customerNumber
);
$invoiceAddressArray = $this->ds->select($query, $paramType, $paramValue);
return $invoiceAddressArray;
}
Or should I pass the string "Invoice" when I call the function?
$invoiceAddresses = $customer->getCustomerInvoiceAddresses($customerNumber, "Invoice");