what i want to perform (globally) is to import a
csv file that contains data such as book_title, author, and the cover image of the books. The csv file is loaded, book_title and author are stored in their respective tables but for pictures, what i want is to put them manually (ftp for example) on a folder (doesn't matter if it's my default public folder or a new one) and store data in tables like :
In my csv file, and for pictures column i just write filenames of every picture.
At the moment, i'm confused and this is my actual code :
$filename_cover = $get_filename.'.jpg'; <===from csv $add_cover_file = db_insert('file_managed') // ->key(array('fid' => rand())) ->fields(array( 'uid' => $user->uid, 'filename' => $filename_cover , 'uri' => 'public://couvertures/'.$filename_couv,<==my file 'filemime' => 'application/octet-stream', 'status' => 1, 'timestamp' => time() )) ->execute();
Now adding on the pictures covers table : (how to put the
$add_couverture = db_merge('field_data_field_photo_de_couverture') ->key(array('entity_id' => $newNode->nid, 'field_photo_de_couverture_fid'=>$add_couv_file->fid )) ->fields(array( 'field_photo_de_couverture_fid'=>$get_fid , 'entity_id' => $newNode->nid, 'delta' => 0, 'bundle' => 'livre', 'entity_type' => 'node' )) ->execute();