<?php 

include("db_connection.php");
$Mainclass=new DB_Controller();
$collection_name = $Mainclass->real_escapes($_REQUEST['collection_name']);

$active = "Yes";
$datetime = date('Y-m-d H:i:s');

$num_check_sql=$Mainclass->dbh->prepare("SELECT SLN FROM gold_collection_master WHERE collection_name=? and active=?"); 
$num_check_sql->bind_param("ss",$collection_name,$active);
$num_check_sql->execute();
$num_check_qry=$num_check_sql->get_result();
$collection_check=$num_check_qry->num_rows;

if($collection_check ==0){
	
$insert_sql=$Mainclass->dbh->prepare("INSERT INTO gold_collection_master (collection_name,active,added_on) VALUE (?,?,?) ");
$insert_sql->bind_param("sss",$collection_name,$active,$datetime);
$insert_sql->execute();
$insert_sql->close();	

echo $last_id = mysqli_insert_id($Mainclass->dbh);
	
}


else{

echo 0;

}

$num_check_sql->close();

?>