我试图在php中的一个案例中添加2个函数。
我有两张桌子
当我点击一个按钮,一个记录从orcamento到trabalho,但是记录仍然保留在orcamento上,有没有办法删除它?我将在下面粘贴我的代码
case "aceitar_o": {
$stmt = $conn->prepare("INSERT INTO trabalho (user, NomeCliente, mail, Telefone, descricao, estado) VALUES (:user, :NomeCliente, :mail, :Telefone, :descricao, 'Aprovado')");
$stmt->bindParam(':user', $user);
$stmt->bindParam(':NomeCliente', $NomeCliente);
$stmt->bindParam(':mail', $mail);
$stmt->bindParam(':Telefone', $Telefone);
$stmt->bindParam(':descricao', $descricao);
$stmt->bindParam(':estado', $estado);
break;
}是否有可能在“休息”之后再添加一个漏斗?
发布于 2018-05-17 20:21:34
不,你不能在break之后执行任何事情。
中断结束当前的执行,同时或切换结构.
-http://php.net/manual/en/control-structures.break.php
您可以创建两个函数,并将它们包含在case中。
case "aceitar_o": {
$values = array('user' => $user, 'nome' => $NomeCliente, 'mail' => $mail, 'fone' => $Telefone, 'descri' => $descricao, 'estado' =>$estado);
update($conn, $values);
delete($conn, $values);
break;
....
function update($conn, $params) {
$stmt = $conn->prepare("INSERT INTO trabalho (user, NomeCliente, mail, Telefone, descricao, estado) VALUES (:user, :NomeCliente, :mail, :Telefone, :descricao, 'Aprovado')");
$stmt->bindParam(':user', $params['user']);
$stmt->bindParam(':NomeCliente', $params['nome']);
$stmt->bindParam(':mail', $params['mail']);
$stmt->bindParam(':Telefone', $params['fone']);
$stmt->bindParam(':descricao', $params['descric']);
$stmt->execute(); // or you could just pass the $values to the execute if you name the index the same as the placeholders
}此外,您没有命名的estado占位符。在当前查询中,它是一个静态值。
https://stackoverflow.com/questions/50399312
复制相似问题