<?php


function api_pricehash($hash){

    $pricesql = "
    SELECT 
        `price_id`, `pricename`, `BeginDate`, `category_id`, `pages`, `pdf`, `html`, `author` 
    FROM 
        `price`
    LEFT JOIN 
        price_authors ON price.priceauthor_id = price_authors.author_id    
    WHERE 
        `pricehash` = '$hash'
    LIMIT 1 
    ";

    $price = db_get($pricesql);

    if (!isset($price['price_id']))
        return ['error' => 'not found hash'];
    else
        return $price;    


}


function apipage_kuri($price_id, $page = 1){


    $newsql = "
    SELECT 
       news_id, title, text, img
    FROM
        `news`
    WHERE
        `price_id` = '$price_id'
    AND
        `page` = '$page'

    ";

  $news  = db_get($newsql);
  
  return $news;

}