I'm not sure if this is computed fields fault, but i have following in the computed field:

$prosentit=$node->field_percentage_in_month[0]['value'];
$kuukausi=$node->field_resurssit_months[0]['value'];
$kayttaja=$node->field_resurssit_user[0]['uid'];
$projekti=$node->field_create_project[0]['nid'];
$arr = array( $node->field_resurssit_months[0]['value'] => $node->field_percentage_in_month[0]['value'] );

$savetodb=serialize($arr);

$result = db_query("INSERT INTO `fgidatabase`. `project_data` (`auto_inc`,`uid` ,`pid` ,`data`) VALUES (NULL , '$kayttaja', '$projekti', '$savetodb');");

Now everytime the node is created or edited, instead of one, three separate entries are created in to database, all with the same data(except the auto_inc field ofcourse). Any clue why this is happening? Is the computed field "ran" three times?

Comments

Moonshine’s picture

Category: bug » support
Status: Active » Postponed (maintainer needs more info)

Very hard to say from that information. My guess is that you don't have the field set to store in the DB (since it looks like you are doing that by hand in another table), in which case computed code could get run during node save, update, load, etc creating your multiples. Not really enough information to go on, but you might be able to use $node->op in some way.

pwaterz’s picture

Are you using this with node api hook? If so you need to check the operation. I also I would recommend rewriting your sql to follow drupal standards and to avoid exposing a security vulnerability.

$result = db_query("INSERT INTO {project_data} (`auto_inc`,`uid` ,`pid` ,`data`) VALUES (NULL , '%s', '%s', '%s');",$kayttaja, $projekti, $savetodb );

mmjvb’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (outdated)