I am looping through fresh array and my database array. i wanna compare the price and the availability on specific id and date. this is what i got:
foreach ($this->super_unique($data) as $day_info) {
$data_listing = Array(
'list_id' => $airbnb_id,
'list_price' => $day_info['price']['local_price'],
'list_currency' => $day_info['price']['local_currency'],
'list_date' => $day_info['date'],
'list_available' => $this->check_list_available((int)$day_info['available'])
);
$listings[] = $data_listing;
}
if ($this->Reservations_model->existing_prices(@$listings[0]['list_id']) > 0) {
foreach ($listings as $list_result) {
if ($this->db->where("(list_id = '{$list_result['list_id']}' and list_date = '{$list_result['list_date']}' and list_price NOT = '{$list_result['list_price']}' or list_available NOT = '{$list_result['list_available']}')")) {
$this->db->where("(list_id = '{$list_result['list_id']}' and list_date = '{$list_result['list_date']}')");
$this->db->update('airbnb_lists_price', $list_result['list_available']);
$this->db->update('airbnb_lists_price', $list_result['list_price']);
}
}
echo 'Prices or avilablity change so we need to update';
} else {
$this->db->insert_batch('airbnb_lists_price', $listings);
echo 'Prices not changed all good';
}
}
Getting me
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
NOT
= '70' orlist_available
NOT
= 'FALSE') AND (list_id
= '215583' and ' at line 2
UPDATE `airbnb_lists_price` SET `FALSE` = '' WHERE (`list_id` = '215583' and `list_date` = '2015-11-29' and `list_price` `NOT` = '70' or `list_available` `NOT` = 'FALSE') AND (`list_id` = '215583' and `list_date` = '2015-11-29')`
What am i doing wrong?