Ok, so inserting the following code as a hidden php procedure:
Code: Select all
$con = nuRunQyery($sql);
$sql = "SELECT * FROM My_View";
$result = $con->query($sql);
$rowcount = 0;
$filecount = 1;
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()){
// build logic for splitting file.
$rowcount = $rowcount + 1;
if (($rowcount % 10000) == 0) {
$filecount = $filecount + 1;
}
// join row elements into a string
$rowstr = join(",",$row);
//String Replace commas with Pipes
$rowstr2 = str_replace (',', '|', $rowstr);
//Count number of pipes
$fields = substr_count($rowstr2, '|');
//Calculate the number of empty fields & insert pipes
$emptyfields = str_repeat('|', (26-$fields));
//Concatenate data with empty fields
$rowstr2 .= $emptyfields;
$rowstr2 .= PHP_EOL;
$filename = 'signals2_' . $filecount . '.dat';
//Write data to file
file_put_contents ($filename, $rowstr2, FILE_APPEND);
}//end while
}
and having the Button object set up as: onclick nuRunPHPHidden('Signals_Outfiles);
Results in this error when pressing the button:
"Procedure Signals_Outfiles
/var/www/html/nucommon.php(1254) eval()'dcode
call to a member function query () on array
Traced from...
(line:48)/var/www/html.nuapi.php -nuRunPHPHidden
(line:381)/var/www/html/nucommon.php - nuEval
(line:1254)/var/www/html/nucommon.php -eval"
No outfiles are generated from the PHP.