function biblio_insert in Bibliography Module 5
Same name and namespace in other branches
- 6.2 biblio.module \biblio_insert()
- 6 biblio.module \biblio_insert()
- 7 biblio.module \biblio_insert()
Implementation of hook_insert().
As a new node is being inserted into the database, we need to do our own database inserts.
File
- ./
biblio.module, line 1773
Code
function biblio_insert($node) {
// Prepare the query:
$fields = biblio_get_db_fields();
if (variable_get('biblio_auto_citekey', 1) && empty($node->biblio_citekey)) {
$node->biblio_citekey = biblio_citekey_generate($node);
}
$node->biblio_coins = biblio_coins($node);
foreach ($node as $key => $value) {
if (in_array((string) $key, $fields)) {
$k[] = db_escape_string($key);
$v[] = $value;
$s[] = "'%s'";
}
}
// Insert the node into the database:
db_query("INSERT INTO {biblio} (" . implode(", ", $k) . ") VALUES(" . implode(", ", $s) . ")", $v);
}