function rec_example_load_file_small_ram in Recommender API 7.3
Same name and namespace in other branches
- 7.5 rec_example/rec_example.module \rec_example_load_file_small_ram()
1 string reference to 'rec_example_load_file_small_ram'
- rec_example_settings_form_submit in rec_example/
rec_example.module
File
- rec_example/
rec_example.module, line 108
Code
function rec_example_load_file_small_ram($file_name) {
db_delete('recommender_preference_staging')
->execute();
$ratings_file = fopen($file_name, 'r');
$count = 0;
$values = array();
if ($ratings_file) {
while (!feof($ratings_file)) {
$line = fgets($ratings_file);
$values[] = explode("\t", $line);
$count++;
if ($count % 500 == 0) {
rec_example_batch_insert($values);
$values = array();
}
//db_query("INSERT INTO {recommender_preference_staging}(source_eid, target_eid, score, updated) VALUE (:e1, :e2, :score, :updated)",
// array(':e1' => $fields[0], ':e2' => $fields[1], ':score' => $fields[2], ':updated' => $fields[3]));
}
//rec_example_batch_insert($values);
fclose($ratings_file);
}
else {
drupal_set_message('Cannot load file: ' . $file_name);
}
}