PHP-如何通过一个电话从多个表中删除行?

时间:2018-08-13 15:48:36

标签: php mysql zend-framework

客户打一个电话+12127773456,然后PHP执行以下操作,从多个表中删除所有数据。但是它并没有删除一切 安全地还有剩余数据。

如何安全地在一个呼叫上提交多个删除操作?

$db = Application_Model_Db::db_load();
$currentdate = date("Y-m-j", strtotime( '-1 days' ) );  
try {
  $sql = "delete from table1 where to_days(createdate)<={$currentdate}";     
  $db->fetchAll($sql);
} catch (Exception $ex) {

}

try {
  $sql = "delete from table2 where to_days(createdate)<={$currentdate}";     
  $db->fetchAll($sql);
} catch (Exception $ex) {

}    


try {
  $sql = "delete from table3 where to_days(createdate)<={$currentdate}";     
  $db->fetchAll($sql);
} catch (Exception $ex) {

}  

try {
  $sql = "delete from table4 where to_days(createdate)<={$currentdate}";    
  $db->fetchAll($sql);
} catch (Exception $ex) {

}     

try {
  $sql = "delete from table5 where to_days(createdate)<={$currentdate}";    
  $db->fetchAll($sql);
} catch (Exception $ex) {

}  

0 个答案:

没有答案