function getBook($bid, $dblink)
{
    global $bookname, $author_id, $bookpreview, $bookdate, $bid;
    if ($stm = $dblink->prepare("SELECT * FROM books WHERE id=?")) {
        $stm->execute(array($bid));
        $row = $stm->fetch();
        $stm = NULL;
    }
    $out['name'] = $row['name'];
    $out['author'] = getAuthorById($row['author_id'], $dblink);
    $out['preview'] = $row['preview'];
    $out['date'] = $row['date'];
    $out['date_create'] = $row['date_create'];
    $out['date_update'] = $row['date_update'];
    return $out;
}
Example #2
0
function getBooksList($dblink)
{
    $query = makeSearchQuery();
    if ($stm = $dblink->prepare($query)) {
        $stm->execute();
        $i = 1;
        while ($row = $stm->fetch()) {
            $books[$i]['id'] = $row['id'];
            $books[$i]['name'] = $row['name'];
            $books[$i]['preview'] = $row['preview'];
            $books[$i]['author'] = getAuthorById($row['author_id'], $dblink);
            $books[$i]['date'] = date("d F Y", strtotime($row['date']));
            $books[$i]['date_create'] = user::cuteDate($row['date_create']);
            $i++;
        }
        $stm = NULL;
    }
    return $books;
}