<?php

  require '../conf/config.php';
  require './commonDB.php';

  //////////////////////////////////  Connecting with DB
  if( !$conn = new mysqli($host, $user, $pswd, $db)) {
    error_log("Connection failed.\n");
    exit;
  }

  $prm_obj_id = $_POST['prm_fa_gene'];
  $cdslen = getCDSLength($conn, $prm_obj_id);
/*
  $cdslen = 0;
  $query = "select pos,end from sys_track where id=? and (type='CDS' or type='cds') order by pos";
  $stmt = $conn->stmt_init();
  $stmt->prepare($query);
  $stmt->bind_param("s", $prm_obj_id);
  $stmt->execute();
  $stmt->store_result();
  $stmt->bind_result($row0,$row1);
  while ($stmt->fetch()) {
      $cdspart = ($row1-$row0+1);
      $cdslen = $cdslen + $cdspart;
  }
  $stmt->free_result();
  $stmt->close();
*/
  echo $cdslen;
?>
