function _freelinking_store in Freelinking 6.2
Same name and namespace in other branches
- 5 freelinking.module \_freelinking_store()
- 6 freelinking.module \_freelinking_store()
2 calls to _freelinking_store()
File
- ./
freelinking.module, line 506
Code
function _freelinking_store($phrase, $path, $args = NULL) {
// store freelinking pair in the db
$hash = md5($phrase . $path . $args);
$query = "SELECT hash FROM {freelinking} WHERE phrase = '%s'";
$result = db_query($query, $phrase);
$num_rows = FALSE;
while ($dbobj = db_fetch_object($result)) {
$num_rows = TRUE;
$dbhash = $dbobj;
}
if (!$num_rows) {
// not in the db
$query = "INSERT INTO {freelinking} (hash, phrase, path, args) VALUES ('%s', '%s', '%s', '%s')";
$result = db_query($query, $hash, $phrase, $path, $args);
}
else {
// in the db, but does it match?
if ($dbhash->hash != $hash) {
// hashes don't match, replace db entry with new values
$query = "UPDATE {freelinking} SET hash = '%s', path = '%s', args = '%s' WHERE phrase = '%s'";
$result = db_query($query, $hash, $path, $args, $phrase);
}
// endif hashes don't match
}
// endifelse row found
}