function properties_sql_properties_template_save in Dynamic properties 7
Save a template object.
Parameters
$template: Template object.
File
- properties_sql/
properties_sql.module, line 216 - This module implements the attribute and category API with a SQL backend.
Code
function properties_sql_properties_template_save($template) {
db_merge('properties_template')
->key(array(
'name' => $template->name,
))
->fields(array(
'label' => $template->label,
))
->execute();
// First, remove all existing category connections.
db_delete('properties_template_category')
->condition('template_name', $template->name)
->execute();
$insert = db_insert('properties_template_category')
->fields(array(
'template_name',
'category_name',
'weight',
));
foreach ($template->categories as $category) {
$insert
->values(array(
'template_name' => $template->name,
'category_name' => $category->name,
'weight' => $category->weight,
));
}
$insert
->execute();
}