当从 Facebook API
输入每个 tagged_places
时,id
和 place_id
作为相同的随机输入数字。
当我在输入之前将对象打印到屏幕上时,id
和 place_id
与输入到数据库中的数字完全不同。
这些数字应该彼此是唯一的,但是来 self 的 FB 用户帐户的数据库中的每个条目都具有相同的 id
和 place_id
相互匹配。
有人知道我遇到的这个问题吗?我需要 id 是唯一的,以便我可以使用它来识别重复插入到我的数据库中。
EDIT 我注意到在我的数据库中输入的每个新条目的数字都是相同的数字,有 10 位数字。我想这可能是一个电话号码……编辑
这是变量输出中的 ID 示例,
[id] => 10202525749041541
这就是数据库 2147483647
这是我的插入代码,
<?php
$stmt = $con->prepare('
INSERT INTO taggedPlaces
(id, created_time, place_id, city, country, latitude, longitude, state, street, zip, name)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
');
foreach($graphObject['tagged_places']->data as $data) {
if (time() - strtotime($data->created_time) < 86400) {
$stmt->execute(array(
$data->id,
$data->created_time,
$data->place->id,
$data->place->location->city,
$data->place->location->country,
$data->place->location->latitude,
$data->place->location->longitude,
$data->place->location->state,
$data->place->location->street,
$data->place->location->zip,
$data->place->name
));
}
}
echo '<pre>' . print_r( $graphObject, 1 ) . '</pre>';
?>
最佳答案
我的问题是 Mysql 字段为 id
和 place_id
设置为 int
int 最大值为 2147483647
我试图输入一个值 10202525749041541
此问题的解决方案是将 Mysql 字段从 INT
更改为 BIGINT
关于php - 使用 Facebook API ID 向数据库输入值对于所有条目都是相同的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24253838/