Check if it exists in table before inserting

This commit is contained in:
Rosiak
2016-02-27 16:23:58 +01:00
parent 73149f3f19
commit 5a831c6dbc

View File

@@ -1448,9 +1448,11 @@ function rrdtest($path, &$stdOutput, &$stdError) {
}
function create_state_index($state_name) {
if (dbFetchRow('SELECT * FROM state_indexes WHERE state_name = ?', array($state_name)) === false) {
$insert = array('state_name' => $state_name);
return dbInsert($insert, 'state_indexes');
}
}
function create_sensor_to_state_index($device, $state_name, $index)
{