hi
i tried this module and it worked but the unique node name is made out of two cck fields. can i use the module with two cck fileds?
say i add to the .module file this:
// CCK field as unique identifier
$IMPORT_UNIQUE_ID_NAME1 = 'field_item_number';
$IMPORT_UNIQUE_ID_NAME2 = 'field_sale_number';
$IMPORT_UNIQUE_ID_IS_CCK = TRUE;
what do i need to do here to get the query to work?
$unique_id_value = $form['#post']['cck:'.$IMPORT_UNIQUE_ID_NAME.':value'][0];
$query = 'SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s_value = "%s"';
and in the qurey
$row = db_fetch_array(db_query($query, $IMPORT_NTYPE, $IMPORT_UNIQUE_ID_NAME, $unique_id_value));
if the query could use two fields i will be very happy...
Comments
Comment #1
etibmw CreditAttribution: etibmw commentedThanks to Tom from CPO.co.il (drupal user tommeir) i got it working
here is what i added
// CCK field as unique identifier
$IMPORT_UNIQUE_ID_NAME = 'field_lot_number'; // Import field that holds the unique identifier
$IMPORT_UNIQUE_ID_NAME_1 = 'field_sale_reference';
$IMPORT_UNIQUE_ID_NAME_2 = 'field_lot_number_letter';
$IMPORT_UNIQUE_ID_IS_CCK = TRUE; // Is the identifier a CCK field?
$IMPORT_NTYPE = 'items'; // Node type to be imported
$IMPORT_UPDATE_DATETIME = TRUE; // Settting: update date/time value?
// Check if item already exists
if ($IMPORT_UNIQUE_ID_IS_CCK) {
// get unique id from cck fields
//$unique_id_value = $form['#post']['cck:field_import_id:value'][0];
$unique_id_value = $form['#post']['cck:'.$IMPORT_UNIQUE_ID_NAME.':value'][0];
$unique_id_value_1 = $form['#post']['cck:'.$IMPORT_UNIQUE_ID_NAME_1.':nid'][0];
$unique_id_value_2 = $form['#post']['cck:'.$IMPORT_UNIQUE_ID_NAME_2.':value'][0];
// build query
//$query = 'SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s = "%s"';
if(!$unique_id_value_2){
$query = 'SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s_value = "%s" AND c.%s_nid = "%s" AND c.%s_value is NULL';
}else{
$query = 'SELECT c.nid, c.vid FROM {content_type_%s} c WHERE c.%s_value = "%s" AND c.%s_nid = "%s" AND c.%s_value = "%s"';
}
and
// execute query
$row = db_fetch_array(db_query($query, $IMPORT_NTYPE, $IMPORT_UNIQUE_ID_NAME, $unique_id_value, $IMPORT_UNIQUE_ID_NAME_1, $unique_id_value_1, $IMPORT_UNIQUE_ID_NAME_2, $unique_id_value_2));
after you edit the lines in the code every thing works
so again thanks tom and all the grate people at CPO.co.il