0

我想插入从 JSON 推文读取的数据库中,而不是特定用户。

谢谢!

$id_str = $row->id_str;
$from_user = $row->user->screen_name;
$from_user_id = $row->user->id;
$from_img = $row->user->profile_image_url;
$text = $row->text;
$fecha = $row->created_at;
$aux = 'CUSTOM FROM USER ID';
$query2 = "INSERT IGNORE INTO 
    twts (
        from_name,
        from_id,
        twt_id,
        twt_text,
        twt_user_img,
        twt_keyword,
        twt_date)
    VALUES (
        '$from_user',
        '$from_user_id',
        '$id_str',
        '".mysql_real_escape_string($text)."',
        '".$from_img."',
        '".mysql_real_escape_string($kw['twt_keyword'])."',
        '$fecha'
    WHERE $aux == 'CUSTOM FROM USER ID')";
 $reply2 = mysql_query($query2) or die("[ ".date('Y-m-d h:i:s')." ] Error MySQL ".mysql_error()." \n");

来自用户 ID 的自定义

4

1 回答 1

0

您可以使用基本的 IF php 语句:

$id_str = $row->id_str;
if ($id_str != 'YOUR_CUSTOM_ID') {
    ...DO THE SQL INSERT HERE!
} else {
    print "user not allowed";
}

干杯!

于 2013-10-22T12:33:13.967 回答