Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- relevant controller methods:
- function console()
- {
- $data['myError'] = $this->read_openx_data($_SERVER['DOCUMENT_ROOT'] . "/junk/", "file.txt", "database_table_name", "\t", "\n", "1");
- $data['myVar'] = "Hello World<br />";
- $this->load->view('console', $data);
- }
- function read_openx_data($local_path, $filename, $tbl, $delimiter="\t", $terminated="\n", $ignore="1")
- {
- // Load Model and assign custom object name
- // Access like: $this->pdp->function()
- $this->load->model('performance_data_push', 'pdp');
- // Perform the insert
- if($this->pdp->insert_openx_data($local_path, $filename, $tbl, $delimiter, $terminated, $ignore))
- {
- return TRUE;
- }
- else
- {
- // Send out an E-Mail
- // ** See MY_email_helper.php to change recipient
- $this->load->helper('email');
- $error = $this->db->_error_message();
- $subject = "Error Inserting OpenX Data";
- $message = "There was an error inersting the OpenX Data into \"{$tbl}\"."
- . "\n\n\n"
- . "Data Dump\n\n"
- . "Local Path: {$local_path}\n"
- . "Filename: {$filename}\n"
- . "Table name: {$tbl}\n"
- . "Delimiter: {$delimiter}\n"
- . "Terminated At: {$terminated}"
- . "Lines Ignored: {$ignore}";
- send_error_email($subject, $message);
- show_error("Error inserting {$filename} into {$tbl} from {$local_path}. With error: {$error}");
- }
- }
- relevant model methods
- function insert_openx_data($local_path, $filename, $tbl, $delimiter="\t", $terminated="\n", $ignore="1")
- {
- // Define some variables
- $file = $local_path . $filename;
- $table = $tbl;
- // Structure the query for LOAD DATA INFILE
- // Ignores the first line: IGNORE 1 LINES
- $this->db->query('LOAD DATA INFILE "'.$file.'" INTO TABLE '.$table.' FIELDS TERMINATED BY "'.$delimiter.'" OPTIONALLY ENCLOSED BY """" LINES TERMINATED BY "'.$terminated.'" IGNORE '.$ignore.' LINES');
- }
- my view
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=Cp1252">
- <title>OpenX Data Aggregation Tool - Console</title>
- </head>
- <body>
- <?php echo $myVar; ?>
- <?php echo $myError; ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement