我想从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");
CUSTOM FROM USER ID
答案 0 :(得分:0)
您可以使用基本的IF php语句:
$id_str = $row->id_str;
if ($id_str != 'YOUR_CUSTOM_ID') {
...DO THE SQL INSERT HERE!
} else {
print "user not allowed";
}
干杯!