Hi all,
I'm starting with my first drupal (5.7) module...
I want to build a complex custom node type by code (I prefer than with CCK, not to be dependant of such a big module, and also to be sure than nobody can change the structure without change the code too, because I'll have many actions on differents fields and their relations).
My problem is about management of multiple values, howto link a list of values to a node ?
e.g. with several subjects linked to a node
I try first the tables my node type: node_edures(nid,description) a bridge table: edures_fields_subjects(sid,nid) subjects table: edures_subjects(sid,subject)
But then, in edures_load(&$node) I can't return an array in a property of my node that doesn't exists...
So I tried this design (fssid means fieldset_subject_id): node_edures(nid,description,fssid) edures_fs_subjects(fssid,sid) edures_subjects(sid,subject)
And my function edures_load become :
$obj = db_fetch_object(db_query('SELECT * FROM {node_edures} WHERE nid = %d', $node->nid)); $subjects = db_query('SELECT subject FROM {edures_fs_subjects} fss LEFT JOIN {edures_subjects} s USING (sid) WHERE fssid = %d;', $obj->fssid); $obj->fssid = array('fssid'=>$obj->fssid, 'subjects'=>array()); $subject = array(); while ($subject = db_fetch_array($subjects)) { $obj->fssid['subjects'][] = $subject['subject']; } return $obj;
But it's quite dirty to change initial int of $node->fssid by an array, don't you think so ?
What's the better way ?