function _favorites_save_favorite_db in Favorites 7
Same name and namespace in other branches
- 7.2 favorites.module \_favorites_save_favorite_db()
Helper function: Store a favorite to the DB.
Used to abstract the storage model (cookie vs. db).
Parameters
$values: The sanitized values submitted by the user.
$account: The user account the favorite belongs to. Must be a registered user (uid > 0); no validation is made here.
See also
1 call to _favorites_save_favorite_db()
- _favorites_save_favorite in ./
favorites.module - Helper function: Store favorites for registered users.
File
- ./
favorites.module, line 421 - The favorites module allows users to bookmark any path within a site.
Code
function _favorites_save_favorite_db($values, $account) {
// Delete an existing entry with the same link to avoid duplicates.
// Workaround for missing "ON UPDATE INSERT" Drupal implementation.
db_delete('favorites')
->condition('uid', $account->uid, '=')
->condition('path', $values['path'], '=')
->condition('query', $values['query'])
->execute();
db_insert('favorites')
->fields(array(
'uid' => $account->uid,
'path' => $values['path'],
'query' => $values['query'],
'title' => $values['title'],
'timestamp' => REQUEST_TIME,
))
->execute();
}