function _uuid_sync_table in Universally Unique IDentifier 7
Helper function that executes the update on the actual table.
1 call to _uuid_sync_table()
- uuid_uuid_sync in ./
uuid.module - Implements hook_uuid_sync().
File
- ./
uuid.module, line 170 - Main module functions for the uuid module.
Code
function _uuid_sync_table($table, $id_field, $uuid_field) {
// Fetch empty records.
$result = db_select($table, 't')
->fields('t', array(
$id_field,
))
->condition(db_or()
->condition($uuid_field, '')
->isNull($uuid_field))
->execute();
// Update empty records.
foreach ($result as $record) {
db_update($table)
->fields(array(
$uuid_field => uuid_generate(),
))
->condition($id_field, $record->{$id_field})
->execute();
}
}