您好eny可以帮助我解决此问题吗?我需要每个dey在18:00h将表“ texirequest”中的所有数据复制到表“ dispo”,并在检查表“ dispo”后删除表“ texirequest”上的所有数据,如果“ dauer_auftrag”的值为1将所有数据复制到“ texirequest” “使用Cronjob
<?php
$dauerauftrag_array = array(1);
$con = mysql_connect("localhost","admin","password");
if(!$con) {
die('could not connect: '.mysql_error());
}
mysql_select_db('admin_transport', $con);
foreach($dauerauftrag_array AS $dauerauftrag) {
$result = mysql_query("SELECT * FROM dispo WHERE dauer_auftrag = '".$dauerauftrag."'");
while($row = mysql_fetch_array($result)) {
mysql_query("INSERT INTO texirequest (id, driver_id, driver_email, driver_name, sender_id, name, typ, sbehalt, Transportar, bfahrer, zinfo, ein_stieg, aus_stieg, dauer_auftrag, status, phoneM, phoneF, termin, termin_austirg, phone, droplocation, location, latitude, longitude, timedate, accept)
VALUES ('".$row['id']."', '".$row['driver_id']."', '".$row['driver_email']."', '".$row['driver_name']."', '".$row['sender_id']."', '".$row['name']."', '".$row['typ']."', '".$row['sbehalt']."', '".$row['Transportar']."', '".$row['bfahrer']."', '".$row['zinfo']."', '".$row['ein_stieg']."', '".$row['aus_stieg']."', '".$row['dauer_auftrag']."', '".$row['status']."', '".$row['phoneM']."', '".$row['phoneF']."', '".$row['termin']."', '".$row['termin_austirg']."', '".$row['phone']."', '".$row['droplocation']."', '".$row['location']."', '".$row['latitude']."', '".$row['longitude']."', '".$row['timedate']."', '".$row['accept']."') ON DUPLICATE KEY UPDATE id = '".$row['id']."', '".$row['driver_id']."', '".$row['driver_email']."', '".$row['driver_name']."', '".$row['sender_id']."', '".$row['name']."', '".$row['typ']."', '".$row['sbehalt']."', '".$row['Transportar']."', '".$row['bfahrer']."', '".$row['zinfo']."', '".$row['ein_stieg']."', '".$row['aus_stieg']."', '".$row['dauer_auftrag']."', '".$row['status']."', '".$row['phoneM']."', '".$row['phoneF']."', '".$row['termin']."', '".$row['termin_austirg']."', '".$row['phone']."', '".$row['droplocation']."', '".$row['location']."', '".$row['latitude']."', '".$row['longitude']."', '".$row['timedate']."', '".$row['accept']."'");
}
}
mysql_close($con);
?>
如果dauer_auftrag = 1,则不会从表“ dispo”复制到表“ texirequest”
我的texirequest表
CREATE TABLE `texirequest` (
`id` int(11) NOT NULL,
`driver_id` varchar(100) NOT NULL,
`driver_email` varchar(100) NOT NULL,
`driver_name` varchar(100) NOT NULL,
`sender_id` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`typ` varchar(100) NOT NULL,
`sbehalt` varchar(100) NOT NULL,
`Transportar` varchar(100) NOT NULL,
`bfahrer` varchar(100) NOT NULL,
`zinfo` varchar(100) NOT NULL,
`ein_stieg` varchar(100) NOT NULL,
`aus_stieg` varchar(100) NOT NULL,
`dauer_auftrag` varchar(100) NOT NULL,
`status` varchar(100) NOT NULL,
`phoneM` varchar(100) NOT NULL,
`phoneF` varchar(100) NOT NULL,
`termin` varchar(100) NOT NULL,
`termin_austirg` varchar(100) NOT NULL,
`phone` varchar(100) NOT NULL,
`droplocation` varchar(100) NOT NULL,
`location` text NOT NULL,
`latitude` varchar(100) NOT NULL,
`longitude` varchar(100) NOT NULL,
`timedate` text NOT NULL,
`accept` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
这是我的“分配”表
CREATE TABLE `dispo` (
`id` int(11) NOT NULL,
`driver_id` varchar(100) NOT NULL,
`driver_email` varchar(100) NOT NULL,
`driver_name` varchar(100) NOT NULL,
`sender_id` varchar(100) NOT NULL,
`name` varchar(100) NOT NULL,
`typ` varchar(100) NOT NULL,
`sbehalt` varchar(100) NOT NULL,
`Transportar` varchar(100) NOT NULL,
`bfahrer` varchar(100) NOT NULL,
`zinfo` varchar(100) NOT NULL,
`ein_stieg` varchar(100) NOT NULL,
`aus_stieg` varchar(100) NOT NULL,
`dauer_auftrag` varchar(100) NOT NULL,
`status` varchar(100) NOT NULL,
`phoneM` varchar(100) NOT NULL,
`phoneF` varchar(100) NOT NULL,
`termin` varchar(100) NOT NULL,
`termin_austirg` varchar(100) NOT NULL,
`phone` varchar(100) NOT NULL,
`droplocation` varchar(100) NOT NULL,
`location` text NOT NULL,
`latitude` varchar(100) NOT NULL,
`longitude` varchar(100) NOT NULL,
`timedate` text NOT NULL,
`accept` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
最佳答案
就像'admin_transport'这样写admin_transport,因为这不是已定义的关键字。