Background: I work with phpMyAdmin (MySQL Workbench) in a mysql DB. I write some PHP code to import data in the DB and execute this with the task scheduler of windows. <= this works fine!
My Topic: Now I want to export some data into a file in a Windows folder. At first I write the SQL code in phpMyAdmin to see some debug-infos. Independent of php my sql-query works fine.
If I put the code in the php-programm my export didn't work. I think the problem occurs because of my path specification. The other programmparts, specially the Update-Part, do what they should.
Here is my code:
<?php
include "../config.php";
$conn = new mysqli('192.168.10.120', 'alb5', 'alb5','testdatenbank');
if ( $conn->connect_error ) {
die( "Connection failed: " . $conn->connect_error );
} //$conn->connect_error
$sql = "set @sql = concat(\"SELECT `LS_ID_Nr`, `Stk_pro_Krt_DL` * `Krt_DL` + `RB_Stk_pro_Krt_DL` * `RB_Krt_DL`, `Umstellzeit`, `Produktionszeit`, `Teilmeldung`, `Fertigmeldung`
INTO OUTFILE 'C:/Temp/Export/Test - \", DATE_FORMAT(NOW(), '%Y%m%d%H%i%s'),\" - Test.txt'
fields terminated by ';'
lines terminated by '\r\n'
From praemie where Proof_P = 0\");";
$sql = "prepare s1 from @sql;";
$sql = "execute s1;";
$sql = "DROP PREPARE s1;";
$sql = "UPDATE praemie SET Proof_P = 1 WHERE Proof_P = 0;";
$result = $conn->query( $sql );
echo("Error description: " . mysqli_error($conn));
?>
Does anybody have an idea how I specify a export-path, with sql in php? Thanks in advance.