user1987
user1987

Reputation: 1

Write values to CCK field from content type Drupal 6

I'm using Drupal 6, I try to developed my own Drupal module. I can retrieve a node from the database in my module. Now I want to try to write some values for example number 6 to a CCK field for example field_grade_student. I try to this this the following way, here I try to assign the student the number. Another number can priviously be assigned so I add it.. . But if i look to the database nothing is happen? must I write a database query to solve this issue or what i'm doing wrong? My question is, how can write values to cck field without a sql query?

foreach($currentArray as $value) { // $currentArray is node student.
    $value->field_grade_student[0]['value'] += 6;
}

Upvotes: 0

Views: 506

Answers (1)

Laxman13
Laxman13

Reputation: 5211

I would assume you mean "without using a manual sql query", since to update a node a db query has to be run at some point.

If you already have the node object, you might want to look at node_save(). node_save() will take care of the updating of the node in the database.

Upvotes: 1

Related Questions