function _insert_replace_helper($table, $data, $format = null, $type = 'INSERT')
{
if (!in_array(strtoupper($type), ['REPLACE', 'INSERT'])) {
return false;
}
$this->insert_id = 0;
$formats = $format = (array) $format;
$fields = array_keys($data);
$formatted_fields = [];
foreach ($fields as $field) {
if (!empty($format)) {
$form = ($form = array_shift($formats)) ? $form : $format[0];
} elseif (isset($this->field_types[$field])) {
$form = $this->field_types[$field];
} else {
$form = '%s';
}
$formatted_fields[] = $form;
}
$sql = "{$type} INTO `{$table}` (`" . implode('`,`', $fields) . "`) VALUES (" . implode(",", $formatted_fields) . ")";
return $this->query($this->prepare($sql, $data));
}