Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P82
(An Untitled Masterwork)
Active
Public
Actions
Authored by
stwalkerster
on Dec 13 2016, 8:55 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Tags
None
Referenced Files
F5956:
Dec 13 2016, 8:55 PM
2016-12-13 20:55:14 (UTC+0)
Subscribers
None
<?php
$pdo
=
new
PDO
(
'mysql:host=localhost;dbname=stwalkerster_ed_explore'
,
'stwalkerster'
,
'fl4smells'
);
$query
=
$pdo
->
query
(
'SELECT * FROM system WHERE x IS NULL OR y IS NULL OR z IS NULL'
);
$update
=
$pdo
->
prepare
(
'UPDATE system SET x = :x, y = :y, z = :z WHERE id = :id'
);
$systems
=
$query
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
foreach
(
$systems
as
$system
)
{
$data
=
file_get_contents
(
"https://www.edsm.net/api-v1/system?systemName="
.
urlencode
(
$system
[
'name'
])
.
"&coords=1"
);
if
(
$data
===
"[]"
){
continue
;
}
$data
=
json_decode
(
$data
);
$update
->
execute
(
array
(
':x'
=>
$data
->
coords
->
x
,
':y'
=>
$data
->
coords
->
y
,
':z'
=>
$data
->
coords
->
z
,
':id'
=>
$system
[
'id'
],
));
sleep
(
1
);
}
Event Timeline
stwalkerster
created this paste.
Dec 13 2016, 8:55 PM
2016-12-13 20:55:14 (UTC+0)
•
import-bot
changed the edit policy from "All Users" to "
Community
(Project)".
Feb 3 2017, 3:03 PM
2017-02-03 15:03:30 (UTC+0)
Log In to Comment