I ran into a problem where I don’t know how to check the uniqueness of some fields in the database, I don’t have a field where only 1 element is unique, of course, except for the id, but I can’t compare values by id because this is auto_increment and not manual input.
Question: how to compare if there are fields label, table_id
$this->db->table('context')->insert([
'type_flow' => $node['name'],
'title' => $node['data']['title'],
'label' => $item['label'],
'type' => $item['type'],
'value' => $item['value'],
'table_id' => $node['id'],
]);
I need to implement this in codeigniter and if there is a comparison method, can you tell me of course I think I could manually try to extract fields from the database and compare but I think the code would not be entirely correct
If you need more data, please write in the comments.
my try:
$db_conn = $this->model->where('type_flow', $item['field'])->where('table_id', $node['id'])->where('type_flow', 'conditions')->first() ? true : false;
if (!$db_conn) {
$this->db->table('context')->insert([
'type_flow' => $node['name'],
'title' => $node['data']['title'],
'label' => $item['field'],
'type' => $item['type'],
'value' => $item['value'],
'table_id' => $node['id'],
]);
}