5

我制作了一个电子邮件脚本,一旦 wp_mail 有结果就应该更新。由于某种原因,我的价值不会更新。我错过了什么吗?我正在接收邮件,所以 wp_mail 可以工作。

干杯!

$email_result = wp_mail( $to, $subject, $message, $headers );

if( $email_result ){//wp_mail() processed the request successfully
    global $wpdb;
    $table_name = $wpdb->prefix . "wpsc_coupon_codes";
    $coupon_id = $ereminder->ID;

$ereminders = $wpdb->query( $wpdb->prepare("
    UPDATE *
    FROM $table_name
    SET reminder = 1
    WHERE ID = $coupon_id
") );

}
4

7 回答 7

22

尝试这个:

$wpdb->update( $table_name, array( 'reminder' => 1),array('ID'=>$coupon_id));
于 2013-11-17T09:33:39.767 回答
6

尝试这个

UPDATE  $table_name
SET reminer = 1
WHERE ID = $coupon_id
于 2013-03-03T12:02:11.323 回答
4

您可以更改而不是 (UPDATE * FROM)

$ereminders = $wpdb->query($wpdb->prepare("UPDATE $table_name SET reminer='1' WHERE ID=$coupon_id"));

并且不使用休息。

谢谢你。

于 2013-03-03T12:48:30.473 回答
3

我们可以$wpdb->update像这样使用:

 global $wpdb;
 $table_name = $wpdb->prefix.'your_table_name';
 $data_update = array('row_name_1' => $row_data_1 ,'row_name_2' => $row_data_2);
 $data_where = array('row_name' => $row_data);
 $wpdb->update($table_name , $data_update, $data_where);
于 2020-03-09T08:46:16.777 回答
2

我的工作示例:

$result = $wpdb->update(
    $wpdb->prefix .'sae_calendar', 
    array( 
        'year' => $year,
        'quarter' => $quarter,
        'start_date' => $start_date,
        'end_date' => $end_date,
        'reservation_start_date' => $reservation_start_date,
        'reservation_end_date' => $reservation_end_date 
    ), 
    array(
        "id" => $id
    ) 
);
于 2015-10-28T11:23:37.320 回答
0
UPDATE $table_name
SET reminder = 1
WHERE ID = $coupon_id

另外,改变:

$coupon_id = $ereminder->ID;

$coupon_id = $ereminder->id;

资料来源:使用 $wpdb 更新查询 - Wordpress 教程

于 2014-08-10T01:52:47.020 回答
0
<?php 
  global $wpdb;
    if(isset($_POST['progress'])){
    $table=t_test;
    $data=array('client_development'=>$_POST['Progress']);
    $where=array('p_id'=>$_SESSION['id']);
    $format=("%d");
    $whereFormat=("%d");
    $result4=$wpdb->UPDATE($table,$data,$where,$format,$whereFormat);
  }
?>
<form method="post">
  <input type="text" name="Progress">
  <input type="submit" name="progress" value="Prog%">
</form>
<?php 
if(isset($_POST['progress'])){
$table=t_test;
    $data=array('client_development'=>$_POST['Progress']);
    $where=array('p_id'=>$_SESSION['id']);
    $format=("%d");
    $whereFormat=("%d");
    $result4=$wpdb->UPDATE($table,$data,$where,$format,$whereFormat);
}
?>
<form method="post">
  <input type="text" name="Progress">
  <input type="submit" name="progress" value="Prog%">
</form>
于 2017-01-30T08:13:08.720 回答