我想在下面的陈述中SELECT
device_token
一个名为 $result = query("SELECT IdPhoto, title, IdUser FROM photos p ORDER BY IdPhoto DESC LIMIT 50") ;
的字段。我的主要目标是选择令牌并将其存储在新变量中。
function stream($IdPhoto=0, $token) {
if ($IdPhoto==0) {
//Here's where I want to grab the device_token
$result = query("SELECT device_token, IdPhoto, device_token, title, IdUser FROM photos p ORDER BY IdPhoto DESC LIMIT 50", $token) ;
} else {
//do the same as above, but just for the photo with the given id
$result = query("SELECT IdPhoto, title, l.IdUser, username FROM photos p JOIN login l ON (l.IdUser = p.IdUser) WHERE p.IdPhoto='%d' LIMIT 1", $IdPhoto);
}
if (!$result['error']) {
// if no error occured, print out the JSON data of the
// fetched photo data
print json_encode($result);
} else {
//there was an error, print out to the iPhone app
errorJson('Photo stream is broken');
}
}
以下是该功能的主体以及我尝试过的内容:
($IdPhoto==0)
$token
参数是否妨碍device_token
变量?如果是这样,怎么能正确地做这些事情呢?
选择$token
将其存储在名为$token
将InteractionManager.runAfterInteractions(() => {
this.listView.scrollTo({y:0, animated: false});
});
参数添加到函数名称
答案 0 :(得分:2)
使用这种方式:
$result = query("SELECT photos.device_token, IdPhoto, title, l.IdUser, username FROM photos p JOIN login l ON (l.IdUser = p.IdUser) ORDER BY IdPhoto DESC LIMIT 50");
两个表中可能都有device_token
,结果是从另一个表中得到空device_token
。