<?php

require dirname(__FILE__).'/../common.php';
require dirname(__FILE__).'/../lib/auth.php';

$query_builder = $db_conn->createQueryBuilder();

$query = $query_builder->select('id,doi,journal,title,authors,arxiv,year,owned')->from('publications');
$stmt = $query->executeQuery();
$data = array();
$count = 0;
$all_data = $stmt->fetchAllAssociative();
foreach ($all_data as $row) {
    $data[$count] = ["ads"=>$row['id'], "title"=>$row['title'], "authors"=>json_decode($row['authors']), "arxiv" => $row['arxiv'], "year" => $row['year'], "journal" => $row['journal'], "doi" => $row['doi'], "owned" => $row['owned']];
    $count+=1;
}

return_ok(['result'=>$data]);
