I have an array like the below which comes from my db. It holds currency pairs (eg. USD to AUD dollars, etc).
Array
(
[0] => Array
(
[xrate_amount] => 1
[xrate_from] => AUD
[xrate_to] => GBP
[xrate_date] => 2020-12-05 01:50:29
[xrate_rate] => 0.0000000000
)
[1] => Array
(
[xrate_amount] => 1
[xrate_from] => BRL
[xrate_to] => AUD
[xrate_date] => 2020-12-05 02:16:29
[xrate_rate] => 0.0000000000
)
[2] => Array
(
[xrate_amount] => 1
[xrate_from] => JPY
[xrate_to] => AUD
[xrate_date] => 2020-05-12 00:00:00
[xrate_rate] => 0.0139800000
)
[3] => Array
(
[xrate_amount] => 1
[xrate_from] => JPY
[xrate_to] => CAD
[xrate_date] => 2020-05-12 00:00:00
[xrate_rate] => 0.0128100000
I am trying to insert a new currency pair into my db only if the currency pair doesn't already exist in the db. I am trying to write a function that receives $xrate_from and $xrate_to from a form and then search the above array called $inserted_currency (comes from db actually) and returns TRUE is the pair already exists (btw JPY CAD is different than CAD JPY).
I am totally stumped and would appreciated any guidance.
INSERT IGNORE INTOorINSERT INTO ... ON DUPLICATE KEY UPDATE ...